Hey.
I have a php form that adds data to a mysql database but I need some pointers how to go about adding a preview button to the form.
I understand how to check wether the submit button is pressed or wether the preview button is pressed but what I dont get is how to show the user their preview data without losing all the data from the forms themselves.
As far as I know, whenever a form is submitted the page is refreshed so all of the data on the forms would be lost.
Should I somehow save this data and reinsert it to the editable forms, while also showing the data as it would appear as text?
im pretty lost on this right now...
how have others done it in the past?
any help is appreciated... thanks!
Php - Mysql form with a preview button?
Moderator: General Moderators
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
The preview page could contain a normal HTML form, with the following input element:
One input for every value you need to pass to the next page. Those values would still appear to PHP as $_POST['someVal'] on the following page (as long as the form's method attribute is set to post). You could also store a serialized representation of the $_POST superglobal in the $_SESSION superglobal, though the former is a bit more reliable.
Code: Select all
<input type="hidden" name="someVal" value="<?php echo htmlspecialchars($_POST['someVal'])?>" />- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA