Hello,
So I designed a login & registration system for my website using PHP. Everything is fine, except I’m trying to get this “Change Password” working correctly.
In practice it works, but it doesn’t convert my new passwords to MD5. Can anyone tell me how to properly send an MD5 string to MySQL?
Here is the specific line (I think) that need to be converted to MD5:
[code=php]
$sql=mysql_query(“UPDATE members SET passwd=’$newpassword’ where login=’$username'”);
Here is my whole script:
[code=php]<?php
session_start();
$dbhost = localhost;
$dbuser = ”;
$dbpass = ”;
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (‘Error connecting to mysql’);
$dbname = ‘db’;
mysql_select_db($dbname);
$username = $_POST[‘login’];
$password = $_POST[‘passwd’];
$newpassword = $_POST[‘newpassword’];
$confirmnewpassword = $_POST[‘confirmnewpassword’];
$result = mysql_query(“SELECT passwd FROM members WHERE login=’$username'”);
if(!$result)
{
echo “The username you entered does not exist”;
}
else
if($password!= mysql_result($result, 0))
{
echo “You entered an incorrect password”;
}
if($newpassword=$confirmnewpassword)
$sql=mysql_query(“UPDATE members SET passwd=’$newpassword’ where login=’$username'”);
if($sql)
{
echo “Congratulations You have successfully changed your password”;
}
else
{
echo “The new password and confirm new password fields must be the same”;
}
?>
Any suggestions?