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;
MySQL and MD5 password with PHP...
Moderator: General Moderators
Re: MySQL and MD5 password with PHP...
Here you set UserPass = $md5pwmateoc15 wrote: $query = "UPDATE Users SET UserPass = $md5pw WHERE UserID = 123";
Here you're using $array[UserPW]. Before you called the password yielding column "UserPass" while here you call it "UserPW." Also, I believe that the correct syntax would be $array['UserPW'] (or $array['UserPass'])mateoc15 wrote: 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>";
/Edit... I might stand corrected, $array[UserPW] might be correct... seen as it is working on y our test site?
Ahh, it's not where you set the row information but where you pull it out
You said the password column was titled "UserPass" when you set it? When you try and pull out the information you used the coumn "UserPW"... try
You said the password column was titled "UserPass" when you set it? When you try and pull out the information you used the coumn "UserPW"... try
Code: Select all
<?php
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[UserPass]</td>
<td>$array[UserFName]</td><td>$array[UserLName]</td><td>$array[UserEmail]</td></tr>";
}
echo "</table>";
?>