Hi, I am building a members profile page for my new website....
part of the user control panel enables the members to update their 'profiles'...
here is the form which shows them their current data and allows them to submit any changes...
usercp.php?do=profile&panel=1
if($_POST['save'])
{
//attempt to save the settings
if(edit_user($user['username'], $_POST['$name'], $_POST['$sname'], $_POST['$email'], $_POST['$dob_d'], $_POST['$dob_m'], $_POST['$dob_y'], $_POST['hide_dob'], $_POST['$hurl'], $_POST['$aim'], $_POST['$icq'], $_POST['$wlm'], $_POST['$skype'], $_POST['$yahoo'], $_POST['$bio'], $details['$admin']))
{
//Display notice atiprofile
$notice = "Settings Saved";
}
else
{
//same as above
$notice = "Settings Couldn't Be Saved!";
}
if ($details['hide_dob'] == "1") {
$hide = "<input type='checkbox' id='hide_dob' value='1' checked>"; } else {
$hide = "<input type='checkbox' id='hide_dob' value='1'>";}
$con1 = "<h3>$notice</h3>
<form method='post' action='?do=profile&panel=1'>
<table width=\"100%\" border=\"0\" cellspacing=\"0\">
<tr>
<td colspan=\"2\"><h2>Your profile</h2></td>
<td> </td>
<td> </td>
<td> ".
$notice
."</td>
</tr>
<tr>
<td>Your username:</td>
<td><input type='text' value='".$user['username']."' disabled /></td>
<td> </td>
<td>Your avatar:</td>
<td rowspan=\"6\"><img src=\"".$details['avatar']."\" width=\"150px\" height=\"150px\" /></td>
</tr>
<tr>
<td>Your e-mail address:</td>
<td><input type='text' name='email' value='".$user['email']."' /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Your first name:</td>
<td><input type='text' name='name' value='".$details['name']."' /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Your last name: </td>
<td><input type='text' name='sname' value='".$details['sname']."' /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Your Date of Birth</td>
<td><input type='text' name='dob_d' maxlength='2' size='3' value='".$details['dob_d']."' /> / <input type='text' name='dob_m' maxlength='2' size='3' value='".$details['dob_m']."' /> / <input type='text' name='dob_y' maxlength='4' size='5' value='".$details['dob_y']."' /></td>
<td></td>
</tr>
<tr>
<td>Hide My Date of Birth</td>
<td>".$hide."</td>
<td></td>
</tr>
<tr>
<td>Your homepage URL:</td>
<td><input type='text' name='hurl' value='".$details['homeurl']."' />(Please include http://)</td>
<td></td>
</tr>
<tr>
<td><img src=\"images/im_aim.gif\" width=\"17\" height=\"17\">AIM Screen Name:<br>
<input type=\"text\" name=\"aim\" value='".$details['aim']."' id=\"aim\">
<br></td>
<td><img src=\"images/im_icq.gif\" width=\"17\" height=\"17\">ICQ Number:<br>
<input type=\"text\" name=\"icq\" value='".$details['icq']."' id=\"icq\">
<br></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><img src=\"images/im_msn.gif\" width=\"17\" height=\"17\">Windows Live Address:<br>
<input type=\"text\" name=\"wlm\" value='".$details['wlm']."' id=\"wlm\">
<br></td>
<td><img src=\"images/im_skype.gif\" width=\"17\" height=\"17\">Skype Name:<br>
<input type=\"text\" name=\"skype\" value='".$details['skype']."' id=\"skype\"></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><img src=\"images/im_yahoo.gif\" width=\"17\" height=\"17\">Yahoo Address:<br>
<input type=\"text\" name=\"yahoo\" value='".$details['yahoo']."' id=\"yahoo\">
<br></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Your Biography:<br>
Please write a little about yourself<br />and your hobbies etc. here.<br>
<br></td>
<td><textarea name=\"bio\" id=\"bio\" cols=\"24\" rows=\"5\">".$details['bio']."</textarea></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><input type='submit' value='Save Changes' name='save' /></form></td>
<td> </td>
<td> </td>
<td><a href='?do=profile&act=password&panel=1'>Change your password</a></td>
<td><a href='?dp=profile&act=avatar&panel=1'>Change your avatar</a></td>
</tr>
</table>
";}
The bit at the top, registers the submit button has been pressed previously and sends the data to the function in member-functions.php.
here is the function that is called:
member-functions.php edit_user function
//Updates a users details in the database
function edit_user($username, $name, $sname, $email, $dob_d, $dob_m, $dob_y, $hide_dob, $hurl, $aim, $icq, $wlm, $skype, $yahoo, $bio, $admin)
{
if(mysql_query("UPDATE users SET name = '$name', sname = '$sname', dob_d = '$dob_d', dob_m = '$dob_m', dob_y = '$dob_y', hide_dob = '$hide_dob', homeurl = '$hurl', aim = '$aim', icq = '$icq', wlm = '$wlm', skype = '$skype', yahoo = '$yahoo', bio = '$bio', email = '$email', admin = '$admin' WHERE username = '$username'") ) { return true;} else {return false;}
}
The problem I have is that whenever the edit_user function is run, my record gets cleared or returns to default, except from anything which wasn't run by the query to be changed. E.G (username, password, id....)
What is the problem, I have a similar function which updates the password, which works perfectly. What is the problem with this one??
Thanks
Robert