i was following this tutorial
the original sources are at http://www.neoblob.com/phpsquad/index.php?page=sources under login and phpmysql registration, and i cant figure out whats wrong with my do_login.php script.
<?php
$connection = mysql_connect("localhost", "php", "007") or die("error1");
$db = mysql_select_db("user", $connection) or die("error2");
$sql = "SELECT id FROM users
WHERE username='$_POST[username]'
AND password='$_POST[password]'" or die("error3");
$result = mysql_query($sql) or die("error4");
$num = mysql_num_rows($result) or die("error5");
if ($num > 0) {
//USER AND PASS ARE CORRECT
$id = mysql_fetch_assoc($result) or die("error6");
setcookie("auth", "yes", time()+3600);
setcookie("id", $id['id']);
setcookie("username", $id['username']);
header ("Location: main.php") or die("error7");
}else {
header ("Location: incorrect.php") or die("error8");
};
?>
its returning back "error 5" which i added while trying to figure out what the problem was. which mean something is wrong with the code "$num = mysql_num_rows($result) or die("error5");" or one of the variables attached right? i cant figure out what, help appreciated, i also have another question, how do you restrict certain pages based on this info??? thanks again.