Jump to content

[SOLVED] login script issue :(


thewooleymammoth

Recommended Posts

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

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

Someone posted a comment saying "[..] but your attitude not to close td and tr tags drives me crazy :D" 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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.