Forum Moderators: coopster

Message Too Old, No Replies

Php Preview Before Update Mysql

         

amwd07

5:08 pm on Sep 5, 2007 (gmt 0)

10+ Year Member



OK I have an admin page with a form to submit outlet data in to the mysql database. all I want to do is have 3 buttons for the form 1 putting the outlet on hold which is ok the other update with is also ok, the one I am stuck on is Preview,

I need the the admin to be able to check over what has been updated but cannot work out how to display the the data witout updating the databse

anyone any idea's?

Habtom

5:10 pm on Sep 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I understand you correctly, you can do one of the following:

1. Hold the values in session variables
2. Hold the values in hidden text boxes
3. Insert into a temporary table

Hab

amwd07

5:17 pm on Sep 5, 2007 (gmt 0)

10+ Year Member



could you give an example please?

d40sithui

5:21 pm on Sep 5, 2007 (gmt 0)

10+ Year Member



sessions would be the easiest and most efficient method.

<?
session_start();

//to assign session vars
$_SESSION['name'] = $_POST['name'];
$_SESSION['phone'] = $_POST['phone']
//dont forget to clean your vars

?>

//to retrieve in any other page
<?
session_start();

echo $_SESSION['name'];
echo $_SESSION['phone'];

?>

also u can assign arrays and stuff to session variables.

amwd07

5:57 pm on Sep 5, 2007 (gmt 0)

10+ Year Member



thankyou thats makes perfect sense I will try it when I get a minute
once I am on the preview page would i need to use hidden fields to post the form to th edatbase or is there a way I can do as a onclick function for the preview button?

d40sithui

6:14 pm on Sep 5, 2007 (gmt 0)

10+ Year Member



with sessions, you wouldnt need to use hidden fields. just call whatever vars you need from session. as long as you save the data in session variables, it will stay there until the user closes the browser or when you do a session_destroy()

you'll probably have 4 scripts in total
-the first one displays the initial form
-the second validates data, prints error or accepts data and assigns them to session vars, provide a "next" button to the "preview page"
-the preview page, gets the validated data that user entered, which we stored in sessions,
-processes variables stored in sessions, insert in db, email, etc. also you might want to clean up sessions afterwards