Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A new issue for the beginner

Status
Not open for further replies.

tyrannus

MIS
Apr 6, 2006
115
US
I have an application written in PHP. I want the user to be able to make changes to their account information. I have a table with text fields which are populated with the current account info. However I have no clue how to reset the values when they make a change to say their last name.. Here is my code for populating the text fields.
Code:
<table align = center border = 1>
  <tr>
   <td width = 200>First Name:</td>
   <td><input name = "fname" type = "text" value = <?php echo $rowuser['fname']; ?> size = 50></td>
  </tr>
  <tr>
   <td width = 200>Last Name:</td>
   <td><input name = "lname" value = <?php echo $rowuser['lname']; ?> type = "text" size = 50></td>
  </tr>
  <tr>
   <td width = 200>Address:</td>
   <td><input name = "street" value = <?php echo $rowuser['street']; ?> type = "text" size = 50></td>
  </tr>
  <tr>
   <td width = 200>City:</td>
   <td><input name = "city" value = <?php echo $rowuser['city']; ?> type = "text" size = 50></td>
  </tr>
  <tr>
   <td width = 200>State:<font size = "2">(Abbreviation)</font></td>
   <td><input name = "state" value = <?php echo $rowuser['state']; ?> type = "text" size = 50></td>
  </tr>
  <tr>
   <td width = 200>Zip:<font size = "2">(5 or 9 digit)</font></td>
   <td><input name = "zip" value = <?php echo $rowuser['zip']; ?> type = "text" size = 50></td>
  </tr>
  <tr>

Am I doing something wrong?
 
One assumes that when they submit the form, you pick out out the data server-side. The next step is to update the back-end data source based on the changes submitted in the form.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Here is my submit code..
Code:
if($_POST['Change']){
  changeAccount($fname, $lname, $street, $city, $state, $zip, $phone, $store, $email);
 }

and here is the function code..
Code:
function changeAccount($fname, $lname, $street, $city, $state, $zip, $phone, $store, $email){
  $chng = "update users set fname = '$fname', lname = '$lname', street = '$street', city = '$city', state = '$state', zip = '$zip', store = '$store', phone = '$phone' where email = '$email'";
  $chngr = mysql_query($chng) or die(mysql_error());

   $qwerty = "select * from users as u, stores as s where u.email = '$email' and u.store = s.store_num";
   $qwerty1 = mysql_query($qwerty) or die(mysql_error());
   if($qw = mysql_fetch_array($qwerty1)){
     $_SESSION['store'] = $qw['store_name'];
     $_SESSION['etreby'] = $qw['etreby_ip'];
     $_SESSION['fname'] = $qw['fname'];
     $_SESSION['lname'] = $qw['lname'];
     $_SESSION['phone'] = $qw['phone'];
     $_SESSION['storenum'] = $qw['store_num'];
     $_SESSION['email'] = $email;
   $_SESSION['message'] = "<p align = center><font color = blue size = 5>Account Info Has Been Changed!!</font>";
   header ('Location: [URL unfurl="true"]https://test.com/rxrefill/refill.php?sid='.session_id());[/URL]
 }
}

but for somereason, the table doesn't update
 
I like it when I post here, it helps me to look at the code in a different way then through my ssh and I can find the issues.. I have it fixxed..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top