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
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
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
Share on other sites

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.