Hey!
Sorry it took so long to respond ^^.
As far as the identical username issue goes, I still have to get that coded ^^. Thanks for the heads up though!
It worked pretty well once I finally got the chance to mess with it! I would have never thought to combine them all in a single variable, very brilliant move on your part =D. Guess that thinking comes with more experience, hehe.
I did have to change a few of the lines a bit to fit the situation, but this code works perfectly. Thanks so much!
PHP Code:
$newusername = mysql_escape_string($_POST["new_username"]);
$newpassword = mysql_escape_string($_POST["new_password"]);
$newpassword2 = mysql_escape_string($_POST["new_password2"]);
$newemail = mysql_escape_string($_POST["new_e-mail"]);
$newprofile = mysql_escape_string($_POST["new_profile"]);
$currentpassword = mysql_escape_string($_POST["current_password"]);
if ($currentpassword != $data['Password'])
{
echo "<p>I'm sorry, profile information change unsuccessful. The current password that you have entered is incorrect.</p>";
}
else
{
$updateStatement = "";
if ($newusername != NULL)
{
$updateStatement = "Username = '$newusername'";
$_SESSION['User']=$newusername;
}
if ($newpassword != NULL)
{
if (strlen($updateStatement)>5)
{
$updateStatement .= ", ";
}
$updateStatement .= " Password = '$newpassword'";
}
if ($newemail != NULL)
{
if (strlen($updateStatement)>5)
{
$updateStatement .= ", ";
}
$updateStatement .= " Email = '$newemail'";
}
if (strlen($updateStatement)>5) //do we have any changes to post
{
$sql = "UPDATE User_info SET $updateStatement, Profile = '$newprofile' WHERE Username = '$User';";
}
else
{
$sql = "UPDATE User_info SET Profile = '$newprofile' WHERE Username = '$User';";
}
mysql_query ($sql);
if (!mysql_errno()) //checks for mysql error
{
echo "<p>Your chosen profile information has been successfully updated</p>";
}
else
{
$mysql_error = mysql_error();
echo "<p>Your chosen profile information wasn't updated, becuase MySQL got all girly and whinged:-".$mysql_error."</p>";
}
}