Everything is working down to the update query. I have the userid, I have the password, and then nothing happens.
if ($p) { // If everything's OK.
echo $u.'<br />'; echo $p.'<br />'; ?this echos the correct information
// Make the query.
$query = "UPDATE users_tbl SET pass = SHA('$p'+'salt') WHERE user_id='$u'";
echo $query; echo '<br />';
$result = mysql_query ($query) or trigger_error("Query: $query\
<br />MySQL Error: " . mysql_error());
if (mysql_affected_rows() == 1) { // If it ran OK.
// Send an email, if desired.
echo '<h3>Your password has been changed.</h3><br /><p>Return to <a href="/">home</a></p>';
$query3 = "UPDATE users_tbl SET chng_pass=('no') WHERE user_id='$u'";
$result3 = mysql_query ($query3) or trigger_error("Contact site administrator");
} // end of the if it ran ok conditional
} // end of the if ($p) conditional
I get the echo of userid and password. I get the echo of the query. The password does not change.
I suspect I have done something stupid, but I cannot see it.
Cups - Yes, but when I started this project, I didn’t know very much at all. This has been a major learning project and now that I am about finished, I will go through and centralize the code. I did know enough to do that with the database log-in information and a log-in verification.
r937 - cool. I will give that a test tonight when I get home to my computer.
Well, hopefully they stay with you all your working life!
I think a lot depends how quickly you find a dependable solution you should have adopted, and whether you take the time/trouble to refactor your code – well with me it does, but I am aware of my own shortcomings – many people just learn the lesson and move on, I have to really etch it on granite before it sticks.
I now have commented out all of my testing echo statements, and verified that it all works. Now I start learning how I should have been writing the code.
I used the SHA($p+‘salt’) three times in this project. Twice was changing the password and then once verifying the password during log-in.
Thanks for pointing me in the correct direction. I should have me code cleaned up by the end of this weekend and move on to some of my wife’s honey do list.