PHP Programming > Beginners - Learning PHP
keeping text box state
(1/1)
oli8999:
Hi, im new to PHP and have been racking my brains on this problem, would appreciate some help if possible.
I have a text box that displays data from the database, this data can then be changed by the user and when the user clicks on "save" button, the updated data is saved to the db. This is fine, but, the form submits and the text box value goes back to what it was before it was changed. This is fairly simple i think but i cant get it working!
I also have two submit buttons on this page and everything is in one form. Is it possible to get the SQL that updates to run ONLY when the save button is pressed and not when the other button is pressed. At the mo, it runs whenever either button is pressed.
Thanks very much (in advance!) for you time and help
ManiacalV:
Pseudocode:
--- Code: ---<?
if(form has not been submitted)
{
get data from DB
make variables based on data
} else {
get data from POST
make variables based on data
sanity check your data
make error message if anything is bad
if(no error message)
{
submit to DB
header("finished page")
die()
}
}
?>
if error message, show it
display form
<inputs value=variable from either DB or POST from above>
<submit>
--- End code ---
Navigation
[0] Message Index
Go to full version