thewooleymammoth Posted April 23, 2007 Share Posted April 23, 2007 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. Link to comment https://forums.phpfreaks.com/topic/48365-solved-login-script-issue/ Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 change $sql = "SELECT id FROM users WHERE username='$_POST[username]' AND password='$_POST[password]'" or die("error3"); to $sql = "SELECT id FROM users WHERE username='$_POST[username]' AND password='$_POST[password]'" LOL love the video Link to comment https://forums.phpfreaks.com/topic/48365-solved-login-script-issue/#findComment-236456 Share on other sites More sharing options...
trq Posted April 23, 2007 Share Posted April 23, 2007 Honestly, that code is terrible. Do yourself a favor and use a better tutorial, all thats going to do is teach you bad habits. A great free online book is available here. I would dump that other mess right there. Link to comment https://forums.phpfreaks.com/topic/48365-solved-login-script-issue/#findComment-236458 Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 i agree but the video did cheer me up, lol Link to comment https://forums.phpfreaks.com/topic/48365-solved-login-script-issue/#findComment-236462 Share on other sites More sharing options...
The Bat Posted April 23, 2007 Share Posted April 23, 2007 Someone posted a comment saying "[..] but your attitude not to close td and tr tags drives me crazy " and the video poster replied "lol, thanks, yeah, I am not that strict on ending tags". That right there is a huge hint not follow any of his techniques. And he sounds 13 ._. Thank you, thorpe, for that link! I have not known about until now. Very good resource. P.S.: My squal. Link to comment https://forums.phpfreaks.com/topic/48365-solved-login-script-issue/#findComment-236463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.