Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

md5 Password Encryption

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

md5 Password Encryption

Postby meesh2175 » Tue Oct 16, 2012 11:27 am

Hello! I am trying to encrypt my passwords in my database using md5. I can't figure out why it is not working... wondering if a new set of eyes can help.

Code: Select all
...connect to db

$password1 = clean($_POST['password1']);
$password2 = clean($_POST['password2']);

$secret_password = md5($password2);

//Create INSERT query
if($password1 == $password2){
$qry = "UPDATE users
      SET password = '$secret_password'
      WHERE username = '$myusername'";
   
$result = @mysql_query($qry);
}

... code for whether successful or not


Thanks! :)
meesh2175
New php-forum User
New php-forum User
 
Posts: 12
Joined: Thu Feb 16, 2012 1:03 pm

Re: md5 Password Encryption

Postby seandisanti » Tue Oct 16, 2012 11:35 am

What do you mean it's not working? are you getting errors? if so please include error text
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: md5 Password Encryption

Postby meesh2175 » Tue Oct 16, 2012 11:59 am

seandisanti wrote:What do you mean it's not working? are you getting errors? if so please include error text


Hi... I thought my only problem was that the encrypted password wasn't being updated in my db but I removed the md5 part and determined that the new password wasn't being updated at all. Back to my code to figure it out... :?
meesh2175
New php-forum User
New php-forum User
 
Posts: 12
Joined: Thu Feb 16, 2012 1:03 pm

Re: md5 Password Encryption

Postby seandisanti » Tue Oct 16, 2012 12:20 pm

if you post a more complete listing of your code, we may be able to help
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: md5 Password Encryption

Postby meesh2175 » Tue Oct 23, 2012 9:41 am

I figured it out... I wasn't declaring the variable $myusername.

Thanks for offering your help though... :)
meesh2175
New php-forum User
New php-forum User
 
Posts: 12
Joined: Thu Feb 16, 2012 1:03 pm

Re: md5 Password Encryption

Postby seandisanti » Tue Oct 23, 2012 12:49 pm

No problem, glad you got it figured out.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.