I have built a table benutzer with three columns: 'usuario', 'password' and 'redirect', all are 'varchar' and 'usuario' is PRIMARY KEY. Then I try to redirect users depending on the username/pasword-combination they supply.
However, after typing in the combination ad clicking on 'submit', I get this error message:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/ahcehc/paginas/navega1.php on line 21
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/ahcehc/paginas/navega1.php on line 22
Warning: Cannot add header information - headers already sent by (output started at /home/ahcehc/paginas/navega1.php:21) in /home/ahcehc/paginas/navega1.php on line 23
See the actual code:
line 1 <?php
line 2 $db = 'ahcehc';
line 3 $dbuser = 'user';
line 4 $dbpass = 'myPassword';
line 5 $dbhost = 'localhost';
line 6 mysql_connect($dbhost,$dbuser,$dbpass) or die("could not connect");
line 7 mysql_select_db("$db") or die("could not open database");
line 8 if (isset($_POST["usuario"]))
line 9 {
line 10 $usario = $_POST["usuario"];
line 11 }
line 12
line 13 if (isset($_POST["password"]))
line 14 {
line 15 $usario = $_POST["password"];
line 16 }
line 17
line 18 if ( isset($_POST["Submit"]) )
line 19 {
line 20 $sql = "SELECT * FROM benutzer WHERE usuario='$usuario' AND password='$password'";
line 21 $result = mysql_query($sql, $connect);
line 22 $row = mysql_fetch_array($result);
line 23 header("Location: ".$row[redirect]);
line 24 exit;
line 25 }
line 26 else
line 27 {
line 28 ?>
line 29 <form name="form1" method="post" action="navega1.php">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td>
<input type="text" name="usuario">
</td>
</tr>
<tr>
<td><font size="2">Nombre de Usuario</font></td>
</tr>
<tr>
<td>
<input type="text" name="password">
</td>
</tr>
<tr>
<td><font size="2">Contraseña</font></td>
</tr>
<tr>
<td>
<input type="submit" name="Submit" value="Log-in">
</td>
</tr>
</table>
</form>
<?php
}
?>
Any ideas about what's wrong here?



