How can I adjust my edit profile page to only submit user information that has changed from what is already in DB for a particular user. Reason being, I have a unique email check code that stops a user from submitting an email address that is associated with a pre-exiting account. Problem is - it stops submission my profile update form, if a user chooses to update any info but the email because the form resubmits the same email address that is blocked by the unique email check code. Any suggestions?
edit profile script:
The Journey of a Thousand Miles Begins with the First Step...
edit profile script:
Code:
<?php
// include validemail function for this application
require_once('includes/validemail_fns.php');
?>
<?php
// create short variable names
$cfirstname=$_POST['cfirstname'];
$cmidinitial=$_POST['cmidinitial'];
$clastname=$_POST['clastname'];
$cstaddress=$_POST['cstaddress'];
$cunitnum=$_POST['cunitnum'];
$ccity=$_POST['ccity'];
$czip=$_POST['czip'];
$cphone=$_POST['cphone'];
$cemail=$_POST['cemail'];
if (!$cfirstname || !$clastname || !$cstaddress || !$ccity || !$cstate || !$czip || !$cphone || !$cemail)
{
echo '<span class=psparkred12>You have not entered all the required details.</span><br />'
.'<span class=psparkred12>Please go back and try again.</span>';
exit;
}
foreach($_POST as $key => $value) {
$$key = addslashes($value);
}
$db = mysql_pconnect('localhost', 'dbuser', 'password');
if (!$db)
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
// email address not valid
if (!valid_email($cemail))
{
echo '<span class=psparkred12>The email address entered is not a valid email - please go back and try again</span>';
exit;
}
mysql_select_db('realest1_proppost');
//This code checks if an account already exists with entered email address
$query4 = "SELECT cemail FROM customerindex";
$result4 = mysql_query($query4);
while ($row=mysql_fetch_assoc($result4)) {
if ($cemail == $row['cemail']) {
$uniqueemail = "false"; }
}
if ($uniqueemail != "false") {
//do nothing continue
}
else {
echo '<span class=psparkred12>An account with email address, <b>';
echo $cemail;
echo '</b> is already exists</span><br /> <br />';
exit;
}
mysql_select_db('realest1_proppost');
$query2 = "UPDATE customerindex SET cfirstname='$cfirstname', clastname='$clastname', cmidinitial='$cmidinitial', cstaddress='$cstaddress', cunitnum='$cunitnum', ccity='$ccity', czip='$czip', cphone='$cphone', cfax='$cfax', cemail='$cemail' WHERE login='$login'";
$result2 = mysql_query($query2) or die(mysql_error());
if ($result2)
{
echo '<span class=p2><b>Profile Updated</b></span><br /><br />';
echo '<span class=psparkblu12><b>';
echo $myrow["login"];
echo '</b> You have successful updated your user profile for your property posting account</span><br /><br />';
echo '<a class=pmidblu href="proppost_controlpanel.php">Click here to return to Property Post Control Panel</br></a>';
}
?>
The Journey of a Thousand Miles Begins with the First Step...