MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

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 Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old November 8th, 1999, 10:32 PM
g_kas
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Any ideas on how I would allow a user to edit their record in a MySQL database through a PHP script. I want to allow a user to be able to edit/update registration information they have entered previously.

Alternatively, how 'bout a method for pre-filling out a form with data from a MySQL database, allowing the user to edit as necessary, and when submitted posting that record to the database with a new date/time.

Any help appreciated!!

Reply With Quote
  #2  
Old November 9th, 1999, 07:11 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
This is a very simple procedure.

You just have to read the relevent record from the table and use the fields as value in the HTML <input> tags.

To keep this short, I'm assuming you've connected to the db and that $name contains the users name:

<?
$result=mysql_query("select name,address,city,zip,phone from info where name='$name'");
$data=mysql_fetch_array($result);
?>

<form action="changeinfo.php3" method=post>
<input type=hidden name="oldname" value="<? print $data[name] ?>">
NAME:<input type=text name="name" value="<? print $data[name] ?>">
Address:<input type=text name="address" value="<? print $data[address] ?>">

// you get the idea

then in changeinfo.php3 (assuming you've checked the validity of the entries) you can use this query:

"replace into info values ('$name','$address','$city','$zip','$phone') where name='$oldname')"

Using the $oldname allows the user to modify the name and still update the old record. However, using a unique index for this would be better.

HTH

Rod

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Editing MySQL record with PHP


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 1 hosted by Hostway