4 Replies - 368 Views - Last Post: 05 April 2011 - 01:12 PM

#1 amrelewa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 29-March 11

UPDATE info in the same row PHP?

Posted 04 April 2011 - 01:10 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.
<?

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

?>


Mod Edit:
:code:!!!

Is This A Good Question/Topic? 0
  • +

Replies To: UPDATE info in the same row PHP?

#2 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 943
  • View blog
  • Posts: 2,353
  • Joined: 15-February 11

Re: UPDATE info in the same row PHP?

Posted 04 April 2011 - 01:47 PM

What was the output from your code after running this script?

Also always use mysql_real_escape_string to avoid SQL Injection.

If you could tidy up your code with the right indentation it will be much easier to understand.
Was This Post Helpful? 0
  • +
  • -

#3 amrelewa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 29-March 11

Re: UPDATE info in the same row PHP?

Posted 04 April 2011 - 01:53 PM

I didnt got what you mean. There is an html form that connected to this page, where users can save their bank information in the database after they login to their account. Is that helpful ?
Was This Post Helpful? 0
  • +
  • -

#4 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 943
  • View blog
  • Posts: 2,353
  • Joined: 15-February 11

Re: UPDATE info in the same row PHP?

Posted 05 April 2011 - 08:45 AM

View Postamrelewa, on 04 April 2011 - 04:53 PM, said:

I didnt got what you mean. There is an html form that connected to this page, where users can save their bank information in the database after they login to their account. Is that helpful ?


I mean when you submit the form what appears on your screen? Any error messages, a blank page...etc?
Was This Post Helpful? 0
  • +
  • -

#5 amrelewa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 29-March 11

Re: UPDATE info in the same row PHP?

Posted 05 April 2011 - 01:12 PM

Thanks folks .. I fixed the problem
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1