hi
i'm trying to get this function to work correctly
//updating table user
if ($errors1 = 1)
{
$result = mysql_query("update user
set firstname='$firstname'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
if ($errors2 = 1)
{//updating table user
$result = mysql_query("update user
set lastname='$lastname'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
if ($errors3 = 1)
{
//updating table user
$result = mysql_query("update user
set address1='$address1'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
if ($errors4 = 1)
{
//updating table user
$result = mysql_query("update user
set city='$city'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
if ($errors5 = 1)
{
//updating table user
$result = mysql_query("update user
set zip='$zip'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
if ($errors6 = 1)
{
//updating table user
$result = mysql_query("update user
set phone2='$phone2'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
if ($errors7 = 1)
{
//updating table user
$result = mysql_query("update user
set phone3='$phone3'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
if ($errors8 = 1)
{
//updating table user
$result = mysql_query("update user
set institution='$institution'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
if ($errors12 = 1)
{
//updating table user
$result = mysql_query("update mjp1
set dob1='$dob1'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
if ($errors13 = 1)
{
//updating table user
$result = mysql_query("update mjp1
set dob2='$dob2'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
if ($errors14 = 1)
{
//updating table user
$result = mysql_query("update mjp1
set dob3='$dob3'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
if ($errors17 = 1)
{
//updating table user
$result = mysql_query("update user
set major='$major'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
}
return true;
}
what this is supposed to do is - if an error condition exists (user data not long enough, or nonexistent), the variable $errors1 (there's an individual $errors# variable for each possible error) will be changed from 0 to 1, then the user will be presented with a text box to submit new information.
this function should check to see if, say $errors1 is a 0 or a 1. if the value is 0, it proceeds to check the next variable. if the value is 1, then it tries to update the appropriate table in the db with the user's new information. it should then proceed to check the next possible error.
what's happening is that - it seems to be trying to submit all every possible error. even fields which the user has correctly submitted and no error condition exists (i.e, $errors# = 0 and not 1). the fields which the user has submitted correctly get erased, as the function submits blank information into them, as it seems to be trying to submit for every possible error and not submit only the ones that have errors.
am i going about this the right way? comments are welcome
thanks
philosophia