Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.