Hello,
I'll try to give you as much detail as possible. I am building a contact management system. All data in added and displayed via three forms.
Adding the data into the database was a piece of cake. My problem is with the display/edit functionality.
I have three pages that display in data by prefilling in textboxes. Basically, these pages are the add client pages with the data from the database retrieved and stored in sessions. I then echo the appropriate variable to fill in the textbox...for example:
<input name="initial_funding_info" type="text" id="initial_funding_info" value="<? echo $_SESSION[initial_funding_info]; ?>" size="60" maxlength="255">
Still, no big deal. This allows the end user to view all the data availble on the client by viewing each form.
Here is the sticky part....the end user needs to have the ability to make changes to the data when they are displayed.
For example:
1) user looks up client name 'Bubba'
2) database find the data and displays it in the forms.
3) user noticed that the address found on page 1 is incorrect, so they change the address....click next and expect the changes to be saved.
What I did to accomplish #3 above is to place an update query on page two
mysql_query("UPDATE clients SET
address='$_POST[address]'WHERE Id='$_SESSION[Id]'"); */
My thought was that this texbox should always be filled in...either by the values given by the session or by the user typing in a new value. This works....EXCEPT for one BAD bug.
What if the user goes to page 1, page 2, page 3....then decides to go back to back 2 by using browser back button....
What happens?
The update query runs with no data from $_POST[address]. So now the record gets an empty field in the DB.
Remember, this scenerio can happen quiet a bit as this is how they view the client data.
So, I guess my quesiton is...how can I keep this functionality....without blowing up data?
What are my options?
How would you do this?
Thanks for the help?