mtarakji Posted August 23, 2010 Share Posted August 23, 2010 Hey guys I've been writing this login code and ive been having some minor problems i dunno what seemds to be the problem ive tried everything :s Here's the html part of the login, the username and pass are sent by post to login.php below to compare with the ones in the database <form method="POST" action="login.php"> Username : <input type="text" name="username"> Password : <input type="password" name="password"> <input type="submit" value="Login"> </form> $connect=mysql_connect("localhost","swcri_tarakji","xxxxxxxxxx"); mysql_select_db("swcri_working",$connect) or die (mysql_errno().":<b> ".mysql_error()."</b>"); $select_user = mysql_query('select * from users where username = "' . $_POST['username'] . '" and password = "' . md5($_POST['password'] . '"')); if (mysql_num_rows($select_user) != 0) { session_start(); session_register('authorized'); $_SESSION['authorized'] = true; header("Location: protected.php"); exit; } else { header("Location: login_form.php"); exit; } i get the following errors when i try to login : Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/swcri/public_html/working/login.php on line 19 Warning: Cannot modify header information - headers already sent by (output started at /home/swcri/public_html/working/login.php:10) in /home/swcri/public_html/working/login.php on line 30 Pleaassseee help me Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted August 23, 2010 Share Posted August 23, 2010 Take another look at your query string. Pay particular attention to the placement of the md5 hash function parentheses. $select_user = mysql_query('select * from users where username = "' . $_POST['username'] . '" and password = "' . md5($_POST['password'] . '"')); Quote Link to comment Share on other sites More sharing options...
mtarakji Posted August 23, 2010 Author Share Posted August 23, 2010 Take another look at your query string. Pay particular attention to the placement of the md5 hash function parentheses. $select_user = mysql_query('select * from users where username = "' . $_POST['username'] . '" and password = "' . md5($_POST['password'] . '"')); Omg m soo stupid :/ thanks alot bro i fixed it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.