UPDATE info in the same row PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amrelewa
Forum Newbie
Posts: 4
Joined: Mon Apr 04, 2011 4:12 pm

UPDATE info in the same row PHP

Post by amrelewa »

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.

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';
}

?>
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!!!!
TonsOfFun
Forum Commoner
Posts: 54
Joined: Wed Jun 02, 2010 7:37 pm

Re: UPDATE info in the same row PHP

Post by TonsOfFun »

Print out the $email variable and see if it actually the email you are wanting to alter.
amrelewa
Forum Newbie
Posts: 4
Joined: Mon Apr 04, 2011 4:12 pm

Re: UPDATE info in the same row PHP

Post by amrelewa »

Thaaaaaanks
Maq
Forum Newbie
Posts: 4
Joined: Thu Apr 16, 2009 10:34 am

Re: UPDATE info in the same row PHP

Post by Maq »

Also, do not use short tags. Instead, use <?php.
Post Reply