PHP md5 Login Script Help

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Rdubya
New php-forum User
New php-forum User
Posts: 4
Joined: Sat Sep 22, 2012 2:30 pm

PHP md5 Login Script Help

Postby Rdubya » Tue Sep 25, 2012 6:44 pm

Hi All,

I really can't identify where my error is here--any help would be much appreciated:

When a user registers- the following information is sent to the DB

$sql="INSERT INTO ... (..., ..., ..., password, ..., ... )
VALUES (...,..., ..., 'md5($password)',..., ...)";
----------------------------
when i try logging in using this:

$check3 = "SELECT * FROM ...
WHERE ...
AND password = '".md5($_POST['pass'])."'";

-----------------------

When I remove the last line of $check3 everything works fine. I am pretty confident it has to do with the way my passwords are stored and the way password is trying to match the hashed passwords.

Please let me know if you need any other information.

Thanks.
Ryan :help:

User avatar
fady10
New php-forum User
New php-forum User
Posts: 10
Joined: Mon Sep 24, 2012 6:58 pm
Contact:

Re: PHP md5 Login Script Help

Postby fady10 » Tue Sep 25, 2012 8:06 pm

Try to separate the hashing operation from the inserting and selecting operations.
$password = md5($password);
Then use the new $password variable in your sql statement.

Make sure that the password is stored in your table hashed.


Regards,
Fady Joseph
iFunny; The funniest blog ever ! funny comics and pictures

Rdubya
New php-forum User
New php-forum User
Posts: 4
Joined: Sat Sep 22, 2012 2:30 pm

Re: PHP md5 Login Script Help

Postby Rdubya » Wed Sep 26, 2012 3:23 pm

That did it! Very much appreciated!


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot], krotbacca and 1 guest