Jump to content

Using $_POST values across a number of pages ??


PHP Learner

Recommended Posts

Hello everyone,

 

I'm trying to code a section of the site which is like an advertising website (i.e, gumtree) where people can post an Ad on the site and have any responses sent to them via email. The thing is that I have a form where they can enter their details and need to POST the information to the following page which is a preview page of their Ad. I have the form action returning to the same page for validation but I need the $_POST vaules to populate the following page without sending information to the database (in an effort to keep the database clean should they decide not to publish their Ad.

 

There are 3 pages in total CREATE AD > PREVIEW AD (where they can go back and edit if they need to) > Publish AD (where they confirm terms and send to database).  I do have session variables already set after login in and a seperate table to hold the details after they have confirmed the Ad & terms.

 

Any ideas would be greatly appreciated.

 

Thanks, L-plate

Link to comment
Share on other sites

the easiest way would be to use session variables. After someone submitted a form you set a session variable and assign it the value of the $_POST value.   

<?php
if(isset($_POST['gorilla'])){
$_SESSION['gorilla'] = $_POST['gorilla'];
}

?>

 

As for security risks. Any data that is provided (or can be provided, such as $_SERVER['PHP_SELF']) by the end-user can not be trusted. So no matter what you always have to check whether the values are as expected.

Link to comment
Share on other sites

Well its a place to start, and thanks for the help.  Is it the best way to do it do you think? Or is there a better way?

 

L == Learner

the use of the word 'best' is a bit tricky in any case. Sessions are designed to do exactly what you want in this case. There is no reason I can think of not to use it.

 

P.s. if your topic is solved, press the button in the left bottom corner ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.