Jump to content

login code help


mtarakji

Recommended Posts

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 :(

Link to comment
https://forums.phpfreaks.com/topic/211501-login-code-help/
Share on other sites

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'] . '"'));

Link to comment
https://forums.phpfreaks.com/topic/211501-login-code-help/#findComment-1102710
Share on other sites

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 :D

Link to comment
https://forums.phpfreaks.com/topic/211501-login-code-help/#findComment-1102724
Share on other sites

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.