Hi,
My edit_profile function code is below, which appears to work fine.
function edit_profile_form()
{
$username = $_SESSION['username'];
//Pull data from database and place into variables
$password = mysql_query("SELECT password FROM cms_users WHERE username = '$username'");
$password = mysql_result($password, 0);
$email = mysql_query("SELECT email FROM cms_users WHERE username = '$username'");
$email = mysql_result($email, 0);
$location = mysql_query("SELECT location FROM cms_users WHERE username = '$username'");
$location = mysql_result($location, 0);
$fav_rapper = mysql_query("SELECT fav_rapper FROM cms_users WHERE username = '$username'");
$fav_rapper = mysql_result($fav_rapper, 0);
$info = mysql_query("SELECT info FROM cms_users WHERE username = '$username'");
$info = mysql_result($info, 0);
echo"
<form action=\"profile_parser.php\" method=\"post\">
Username : $username<br />
Old Password: <input type=\"text\" name=\"password\" size=\"25\", maxlength=\"20\"><br />
New password: <input type=\"text\" name=\"new_password\" size=\"25\", maxlength=\"20\"><br />
Email Address: <input type=\"text\" name=\"email\" size=\"35\", maxlength=\"200\", value=\"$email\"><br />
Location: <input type=\"text\" name=\"location\" size=\"35\", maxlength=\"20\", value=\"$location\"><br />
Favourite rapper: <input type=\"text\" name=\"fav_rapper\" size=\"35\", maxlength=\"20\", value=\"$fav_rapper\"><br />
Info: <textarea name=\"info\" cols=\"50\" rows=\"3\" maxlength=\"100\">$info</textarea>
<input type=\"submit\" value=\"Update Profile\" name=\"submit\">
<input type=\"reset\" value=\"Reset Entries\" name=\"reset\">
</form>";
}
Below is my profile_parser.php file
<?php
include("includes\db_connect.php");
if ($_POST['email'] != "") {
$email = htmlspecialchars($_POST['email']);
mysql_query("UPDATE cms_users SET email='$email' WHERE username='$username'") or die (mysql_error());
$_SESSION['email'] = $email;
$cemail = "<li>E-mail</li>";
}
if ($_POST['location'] != "") {
$location = htmlspecialchars($_POST['location']);
mysql_query("UPDATE cms_users SET location='$location' WHERE username='$username'") or die (mysql_error());
$_SESSION['location'] = $location;
$clocation = "<li>Location</li>";
}
$fav_rapper = htmlspecialchars($_POST['fav_rapper']);
mysql_query("UPDATE cms_users SET fav_rapper='$fav_rapper' WHERE username='$username'") or die (mysql_error());
$_SESSION['fav_rapper'] = $fav_rapper;
$cfav_rapper = "<li>Favourite Rapper</li>";
if ($_POST['info'] != "") {
$info = htmlspecialchars($_POST['info']);
mysql_query("UPDATE cms_users SET info='$info' WHERE username='$username'") or die (mysql_error());
$_SESSION['info'] = $info;
$cinfo = "<li>Information</li>";
}
echo"
Change Profile Results
<h1>Change Profile Results:</h1>";
if (($cemail) || ($clocation) || ($cfav_rapper) || ($cinfo)) {
echo "The following items have been updated in your profile:<br /><ul>";
if ($cemail) {
echo $cemail;
}
if ($clocation) {
echo $clocation;
}
if ($cfav_rapper) {
echo $cfav_rapper;
}
if ($cinfo) {
echo $cinfo;
}
echo "</ul><br />To view your updated profile, <a href=\"profile.php\">click here</a>.";
} else {
echo "Nothing in your profile has been changed. <a href=\"profile.php\">Click here</a> to return to your profile.";
}
?>
Note : Some of the form fields, such as new password arent being dealt with yet. I am concentrating on getting the opther fields to work firstly.
The trouble is, the database is not updating with the new values. Every database value remains unchanged.
Can anyone help me resolve this problem.
Thankyou
-KLIK