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

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.

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 ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.