Forum Moderators: coopster
I'm building a CMS to upload content articles (just working on adding at the moment). I had it working fine, but then decided I wanted to add a preview screen for proofreading before upload to the database.
At the moment, SUBMIT in the "add_entry" page goes to a preview function, which pulls the variables from $_POST and builds a preview of the content. I then want SUBMIT on the preview page to send those variables through my add_entry function, which will INSERT the entry to the db, however I am unsure how to pass the values entered in the original form (those processed from the $_POST array for preview) on to the second script function. Hitting submit on the preview screen is giving my upload page with errors stating a serious lack of variables.
Is there a quick and easy PHP way to do this? Is there a slow and nasty way to do this? I really don't care which, I just need to get it done!
[sidenote]I've been a contributor in the CSS forum for a while now, and was starting to forget how valuable this forum is for those not in the know. Now that I'm trying to dip my feet into another coding language (PHP), I'm re-realizing how great WebmasterWorld, and all it's knowledgable members, are. Thanks to all of you who provide advice. :)[/sidenote]
cEM
If so, populate those fields using the POST variables you mentioned, naming them the same as the original fields.
Now you just want to either give the Submit button a different name or add a hidden field which you will use to let your script know that it's receiving the final submission so that it can handle the data with a different function.
I was actually hoping to output the preview page as plain HTML, marked up in a way similar to how it will appear when drawn from the database and displayed on the page. To do this, I've taken the variables and sprinkled them throughout html markup stored in a variable and output through print(). If changes are needed, there's a back button to the original form.
Your post is making me rethink things, and I may change the preview screen to have both html and a form populated with the $_POST variables.
I am still curious, though, if there's a way to re-bundle those variables without another form and send them to the final function.
The form will then post all of the data to the script for final processing.
Alternatively you could put all of the values into an array, serialize() it and put it in a single hidden form field. It would of course then need to be unserialize()ed.
Another option that would take a bit more programming would be to store the user's data in a session file or database row before the preview and then re-read it after the accept.
Same outcome with any of the above.