Hiya. I have a script that is run by a <form> which basically allows u to write into inputs the fields username, new username, password, repeat password, comment etc,
The problem is that I want the script to work in a way that, if a field, like the 'new username' has not been touched (no value), then the username wont be changed.
The same kind of rule would go for the other inputs, so that only parts of a user can be edited at a time, without affecting other data.
Im using this script:
- // EDIT USERNAEME
-
-
if ((strlen($username)!==0)||(UserInDB($_POST["username"])))
-
//if(empty($_POST["newusername"]))
-
{
-
if (!(UserInDB($_POST["newusername"])))
-
{
-
mysql_query("UPDATE Users SET login='".$_POST["newusername"]."' WHERE login='".$username."'");
-
$oldname=$_POST["username"];
-
$newname=$_POST["newusername"];
-
echo $user_edited_name=' <b> The user <font color="#FFFFFF"><u>" '.$oldname.' "</u></font> was renamed to <font color="#FFFFFF"><u>" '.$newname.' "</u></font> in the user database.</b> ';
-
//echo '<meta http-equiv="Refresh" content="2; url=index.php"> ';
-
}
-
}
where
- if ((strlen($username)!==0)||(UserInDB($_POST["username"])))
Is supposed to check if the field newusername has been used,
and the function
- if (!(UserInDB($_POST["newusername"])))
Checks if the user (from input "username") exists in the database.
The only problem is that the 'check if field was used' string doesnt work at all. If I want to update a different field, like "comment", I only input the username and leave newusername empty, but the user still gets renamed into " " (nothing).
You also see signs of trying the empty() function, which didnt help.
At least not how I tried it.
So how do I fix this?
Thanks