Jump to content

Problem Password MD5


Recommended Posts

I keep getting Inncorrect password. Help please?

while($info = mysql_fetch_array( $check )){$_POST['password'] = stripslashes($_POST['password']);$info['password'] = stripslashes($info['password']);$_POST['password'] = md5($_POST['password']);//gives error if the password is wrongif ($_POST['password'] != $info['password']) {die('Incorrect password, please try again.');}

Link to post
Share on other sites
echo out both $info['password'] and $_POST['password'](after MD5 summation)
:) I tried! It keeps saying Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in login.php on line 54or something like that.can you try to find what is wrong with my code?
<?php// Connecting$sql= mysql_connect("Sercet","Sercet","Sercet");$database=mysql_select_db("Sercet");if (!$sql){die('Could not connect: ' . mysql_error());}if (!$database){die ("Could not select db: " . mysql_error());}// $$username = $_POST['username'];if (!$_POST['username'] | !$_POST['password']){die('You did not complete all of the required fields');}//Check username$check = mysql_query("SELECT * FROM Member WHERE username = '".$_POST['username']."'")or die(mysql_error());$check2 = mysql_num_rows($check);if ($check2 == 0) {die('That user does not exist in our database. <a href="registering.php">Click Here to Register</a>');}while($info = mysql_fetch_array( $check )){$_POST['password'] = stripslashes($_POST['password']);$info['password'] = stripslashes($info['password']);$_POST['password'] = md5($_POST['password']);//gives error if the password is wrongif ($_POST['password'] != $info['password']) {die('Incorrect password, please try again.');}else{// if login is ok then we add a cookie$_POST['username'] = stripslashes($_POST['username']);$hour = time() + 3600;setcookie(Username, $_POST['username'], $hour);setcookie(Password, $_POST['password'], $hour);}}echo "'Now you can go and upload files here:' . '<a href=member.php>Link</a>"mysql_close($sql);?>
Link to post
Share on other sites

Try removing the stripslashes() (as md5() negates the need), and not modifying $_POST

$password = md5($_POST['password']);//gives error if the password is wrongif ($password != $info['password']) {die('Incorrect password, please try again.');}

Also, check that the column in your table is actually called "password" (not "Password" or something).

Link to post
Share on other sites

What might be a headache saver is to just start off from the basics(mysql_connect(), mysql_close()).From there, check everything to make sure. Double check you don't leave a quote open, or you don't forget semi colons(PHP hates it if you do). Sometimes it's best to just start from scratch.

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...