UPDATE info in the same row PHP
Posted: Mon Apr 04, 2011 4:14 pm
I am building a form where members can add information to their exist row in the data base. When they sign up, I ask for few information such as first name, last name .... After they signup, they to settings page and add their bank account information. When I test my codes, and add bank information, I don't see any updates in the row next my account information. I Think that the problem is with this part (WHERE email='$email'") Since when I add an actual email that is recording the data base, it update the information. The following is the whole php script.
Additional Details
The process is fine, since when I input information in the form and hit save, it shows me that page where my information are saved. "You are successfully edited you account settings!" but when I check mysql, I don't see any changes. Yes, this page is inside user's account, and I create a secured login page.
It might be ($email = $_POST['email'] and should be changed to something else!!!!
Code: Select all
<?
include 'db.php';
$account_type = $_POST['account_type'];
$account_owner_name = $_POST['account_owner_name'];
$account_routing_number = $_POST['account_routing_number'];
$account_number = $_POST['account_number'];
$email = $_POST['email'];
$account_owner_name = stripslashes($account_owner_name);
$account_routing_number = stripslashes($account_routing_number);
$account_number = stripslashes($account_number);
if((!$account_owner_name) || (!$account_routing_number) || (!$account_number)){
echo 'You did not submit the following required information!
';
if(!$account_owner_name){
echo "First Name is a required field. Please enter it below.
";
}
if(!$account_routing_number){
echo "Last Name is a required field. Please enter it below.
";
}
if(!$account_number){
echo "Email Address is a required field. Please enter it below.
";
}
include 'settings.php'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
$sql_account_number_check = mysql_query("SELECT account_number FROM users WHERE account_number='$account_number'");
$account_number_check = mysql_num_rows($sql_account_number_checkā¦
if(($account_number_check > 0)){
echo "Please fix the following errors:
";
if($account_number_check > 0){
echo "<strong>Your account number has already been used by another member in our database. Please submit a different Email address!
";
unset($account_number);
}
include 'settings.php'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}
$info2 = htmlspecialchars($info);
$sql = mysql_query("UPDATE users SET account_type = '$account_type', account_owner_name = '$account_owner_name', account_routing_number = '$account_routing_number', account_number = '$account_number' WHERE email='$email'");
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
include 'register_settings_success.html';
}
?>
The process is fine, since when I input information in the form and hit save, it shows me that page where my information are saved. "You are successfully edited you account settings!" but when I check mysql, I don't see any changes. Yes, this page is inside user's account, and I create a secured login page.
It might be ($email = $_POST['email'] and should be changed to something else!!!!