MySQL and MD5 password with PHP...
Posted: Sat Mar 27, 2004 12:07 am
I have created a basic user table in my database, have no problems with connecting, etc... but when I run my script to enter an MD5 encrypted password into my table, it doesn't appear when I go back to view the record in the table... doesn't give me any kind of error either.
I have checked to make sure that the UserPass field is long enough (varchar 40) to hold the encrypted password... Can't figure out what's up... any ideas? Here are the two code snips I am using for testing:
FIRST, THE DATA ENTRY TO THE DATABASE (can be viewed at http://www.badapplebiz.com/beta/setmypw.php):
$md5pw = md5("password");
$query = "UPDATE Users SET UserPass = $md5pw WHERE UserID = 123";
$results = mysql_query($query);
echo $md5pw . " entered into password field.";
THEN THE VIEWING OF THE EXISTING RECORDS IN THE TABLE (can be viewed at http://www.badapplebiz.com/beta/try.php):
$query = "SELECT * FROM Users";
$result = mysql_query($query);
echo "<table><tr><td>UserID</td><td>UserName</td><td>UserPass</td><td>UserFName</td><td>UserLName</td><td>UserEmail</td></tr>";
while ($array = mysql_fetch_assoc($result))
{
echo "<tr><td>$array[UserID]</td><td>$array[UserName]</td><td>$array[UserPW]</td>
<td>$array[UserFName]</td><td>$array[UserLName]</td><td>$array[UserEmail]</td></tr>";
}
echo "</table>";
mysql_free_result($result);
exit;
I have checked to make sure that the UserPass field is long enough (varchar 40) to hold the encrypted password... Can't figure out what's up... any ideas? Here are the two code snips I am using for testing:
FIRST, THE DATA ENTRY TO THE DATABASE (can be viewed at http://www.badapplebiz.com/beta/setmypw.php):
$md5pw = md5("password");
$query = "UPDATE Users SET UserPass = $md5pw WHERE UserID = 123";
$results = mysql_query($query);
echo $md5pw . " entered into password field.";
THEN THE VIEWING OF THE EXISTING RECORDS IN THE TABLE (can be viewed at http://www.badapplebiz.com/beta/try.php):
$query = "SELECT * FROM Users";
$result = mysql_query($query);
echo "<table><tr><td>UserID</td><td>UserName</td><td>UserPass</td><td>UserFName</td><td>UserLName</td><td>UserEmail</td></tr>";
while ($array = mysql_fetch_assoc($result))
{
echo "<tr><td>$array[UserID]</td><td>$array[UserName]</td><td>$array[UserPW]</td>
<td>$array[UserFName]</td><td>$array[UserLName]</td><td>$array[UserEmail]</td></tr>";
}
echo "</table>";
mysql_free_result($result);
exit;