Hello!
I followed a tutorial to create my authentication script. But it doesn't log in! I put a test/test into the MySQL table. No luck. I keep getting the "Wrong username of password" message, even though I KNOW it's correct. Could someone take a look, see if I am doing something wrong? I wouldn't rule out something inthe php.ini, since I have just installed PHP on my new laptop.
main_login.php passes variables 'myusername' and 'mypassword' to the next script, checklogin:
checklogin.php:
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}