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:
Expand|Select|Wrap|Line Numbers
- // 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"> ';
- }
- }
Expand|Select|Wrap|Line Numbers
- if ((strlen($username)!==0)||(UserInDB($_POST["username"])))
and the function
Expand|Select|Wrap|Line Numbers
- if (!(UserInDB($_POST["newusername"])))
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