PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 1st, 2002, 09:16 PM
Blake Blake is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 125 Blake User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Update form

Didn't know whether to put this in the HTML forum or not, probbaly should have done, but here goes...

I have a form where the user enters their email address. The PHP script checks if the address exists in the MySQL database and if it does, pulls all the information and displays it in text boxes where the user should be able to amend their details. So basically I am doing...
php Code:
Original - php Code
  1.  
  2. $sql = "SELECT * FROM $mailings WHERE email = '$email'";
  3. $result = mysql_query($sql)
  4. $row = mysql_fetch_row($result);
  5. $firstname = $row[1];
  6. $surname = $row[2];
  7. $address1 = $row[3];

etc...
Then I am using
Code:
<input type="text" name="sub_firstname" value="<?php echo $firstname ?>">
.
The problem is (and this may be obvious), that when the user updates any of their details and clicks the button, the details don't get updated!
To update their details I am using
php Code:
Original - php Code
  1.  
  2. $sqlquery = mysql_query("UPDATE $dbtable SET first_name = '$sub_firstname', surname = '$sub_surname', email = '$sub_email', address1 = '$sub_addressline1',
  3.                 address2 = '$sub_addressline2', town = '$sub_town', county = '$sub_county', postcode = '$sub_postcode' WHERE email = '$cfm_email'");
  4.             if(!$sqlquery)
  5.             {
  6.             die("<BR>" . mysql_errno().": ".mysql_error()."<BR>");
  7.             exit;
  8.             }

The confirmation page displays the updated details, but the database still shows the old details. No errors are being reported.
Can anyone shed any light?

Reply With Quote
  #2  
Old November 1st, 2002, 09:36 PM
CSparby CSparby is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 19 CSparby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to CSparby
RE: Update form

Try this:
php Code:
Original - php Code
  1.  
  2. $sql = "UPDATE $dbtable SET first_name = '$sub_firstname', surname = '$sub_surname', email = '$sub_email', address1 = '$sub_addressline1',
  3. address2 = '$sub_addressline2', town = '$sub_town', county = '$sub_county', postcode = '$sub_postcode' WHERE email = '$cfm_email'";
  4. $result = mysql_query($sql, [your connection statement]);
  5. if(!$result)
  6. {
  7. die("<BR>" . mysql_errno().": ".mysql_error()."<BR>");
  8. }

Reply With Quote
  #3  
Old November 1st, 2002, 09:39 PM
Blake Blake is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 125 Blake User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Update form

I think the code for the mysql update is correct. I was under the impression that the text box was keeping it's initial value (...value="<?php echo $firstname ?>") which is why i didn't know whether to put it in the HTML forum.
Is this not the case?

Reply With Quote
  #4  
Old November 1st, 2002, 09:43 PM
CSparby CSparby is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 19 CSparby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to CSparby
RE: Update form

I'm not too sure. I figured it might be the Update statement. You did say that the Confirmation form was showing the updated result but your Database was not. My assumption was that it wasn't connecting to update. I could be wrong though I doubt it.

Reply With Quote
  #5  
Old November 1st, 2002, 09:49 PM
Blake Blake is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 125 Blake User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Update form

It's just that my connection statement is specified just above the code I posted ...

php Code:
Original - php Code
  1.  
  2. dbconnect();
  3.         mysql_select_db($dbname);
  4.        
  5.         $sqlquery = mysql_query("UPDATE $dbtable SET first_name = '$sub_firstname', surname = '$sub_surname', email = '$sub_email', address1 = '$sub_addressline1',
  6.                 address2 = '$sub_addressline2', town = '$sub_town', county = '$sub_county', postcode = '$sub_postcode' WHERE email = '$cfm_email'");
  7.             if(!$sqlquery)
  8.             {
  9.             die("<BR>" . mysql_errno().": ".mysql_error()."<BR>");
  10.             exit;
  11.             }

so really this is doing the same as
php Code:
Original - php Code
  1. $result = mysql_query($sql, [your connection statement]);

Reply With Quote
  #6  
Old November 1st, 2002, 09:50 PM
CSparby CSparby is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 19 CSparby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to CSparby
RE: Update form

Oh well then It might be an HTML problem like you think. HTML really isn't my thing. Sorry I wasn't able to help.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Update form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway