I am using IF statements in a part of a user editing script. This script draws user information from a database and allows you to edit it. My problem with this script is the password editing, I am using MD5 encrypting for this as it is the easiest to use, and I have it set not to show the password in the form for obvious security reasons. Now, when the page is submited, this information is sent over to another page which then submits this to a database. The Only problem was that when I checked the database to see if it had worked, I saw that the password was blank, because of course of the blank field. So I set up this IF statement….
[code=php]
if($edit_password == “”) {
$insertquery = “UPDATE users SET username = ‘$edit_username’, email = ‘$edit_email’, accesslvl = ‘$edit_accesslvl’ WHERE username = ‘$user'”;
} else {
$edit_password = md5($edit_password);
$insertquery = “UPDATE users SET username = ‘$edit_username’, password = ‘$edit_password’, email = ‘$edit_email’, accesslvl = ‘$edit_accesslvl’ WHERE username = ‘$user'”;
}
….to check if the password field is empty, if it is, it doesn’t change the password field(there is a mysql_query that runs below with the value of the variable), but(else), If it has something in it it does edit the password. Only, I ran the code, and it still empty’s the password form, what is up with this? It confuses me as I was sure this would work.