Ok, basicially I am making a script that allows the user to manage settings in their account. To stop it always trying to update each setting, whenever the user only wanted to update one, the script would check to see if the users setting had changed, and if it had, it would check it to see if the data was clean and such, and if it wasnt, it wouldnt try to update it, however now the when the user clicks the update button, nothing happens. Any idea why? And if there is anything that needs to be explained more, please just ask. Here is the script:
PHP Code:
if ($p == "general"){
if($_GET['s'] == ""){
echo"
<b><u>General Settings:</u></b><br><br>
<form action=\"account.php?sid=$sid&p=general&s=update\" method=\"post\">
<b>Name:</b><br>
<input type=\"text\" name =\"username1\" value=\"$username\"><br><br>
<b>Email:</b><br>
<input type=\"text\" name =\"email1\" value=\"$email\"><br><b>
<u>Note:</u> Make sure you enter a valid email address, otherwise your account will be as good as lost.</b><br><br>
<b>Password:</b><br>
<input type=\"checkbox\"><b>Change Password</b><br>
<table border=\"0\" width=\"300\" bgcolor=\"#ffffff\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td width=\"150\">
<u>Current Password:</u>
</td>
<td width=\"150\">
<input type=\"password\">
</td>
</tr>
<tr>
<td width=\"150\" height=\"20\">
</td>
<td width=\"150\" height=\"20\">
</td>
</tr>
<tr>
<td width=\"150\">
<u>New Password:</u>
</td>
<td width=\"150\">
<input type=\"password\">
</td>
</tr>
<tr>
<td width=\"150\">
<u>Confirm New Password:</u>
</td>
<td width=\150\">
<input type=\"password\"><br><br>
</td>
</tr>
</table><br>
<center><input type=\"submit\" value=\"Update\"></center><br>
</form>
";
}else{
if ($username1 !== "$username"){
$query = mysql_query("SELECT username FROM account WHERE username='$username1'");
$num = mysql_num_rows($query);
$query = mysql_query("SELECT username FROM verify WHERE username='$username1'");
$nums = mysql_num_rows($query);
if ($num > 0 || $nums > 0){
echo"<b>Error!</b> The username is already taken.<br>";
}
if (strlen($username1) <= 3) {
echo "<b>Error!</b> The username is too short.<br>";
}
}elseif ($email1 !== "$email"){
$query = mysql_query("SELECT email FROM account WHERE username='$username1'");
$num = mysql_num_rows($query);
$query = mysql_query("SELECT email FROM verify WHERE username='$username1'");
$nums = mysql_num_rows($query);
if ($num > 0 || $nums > 0){
echo "<b>Error!</b> The email you have submitted is already in use.</b>";
}
if (!ereg("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $email1) ){
echo "<b>Error!</b> The email you have submitted has been detected as being invalid.";
}
}else{
mysql_query("UPDATE account SET username='$username1', email='$email1' WHERE id='$id'");
echo"<center><b>[Updated your settings]</b></center>";
}
}
}
Thanks,