PHP Learner Posted September 14, 2011 Share Posted September 14, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/247111-using-_post-values-across-a-number-of-pages/ Share on other sites More sharing options...
PHP Learner Posted September 14, 2011 Author Share Posted September 14, 2011 Or is it possible to use multiple $_SESSION variables so I could make a temporary $_SESSION ['ad_id'] to refer to for just this perticular purpose? Not sure if thats a long way round or has security risks etc... L-plate Quote Link to comment https://forums.phpfreaks.com/topic/247111-using-_post-values-across-a-number-of-pages/#findComment-1269117 Share on other sites More sharing options...
cssfreakie Posted September 14, 2011 Share Posted September 14, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/247111-using-_post-values-across-a-number-of-pages/#findComment-1269122 Share on other sites More sharing options...
PHP Learner Posted September 14, 2011 Author Share Posted September 14, 2011 Ah thankyou, so you can use multiple $_SESSION's? I mean, if I have a session set already say $_SESSION['id'] can I just make another one there on the create ad page called $_SESSION['temp_ad_id'] ? Quote Link to comment https://forums.phpfreaks.com/topic/247111-using-_post-values-across-a-number-of-pages/#findComment-1269124 Share on other sites More sharing options...
trq Posted September 14, 2011 Share Posted September 14, 2011 The $_SESSION array is just like any other only more persistant. Quote Link to comment https://forums.phpfreaks.com/topic/247111-using-_post-values-across-a-number-of-pages/#findComment-1269125 Share on other sites More sharing options...
PHP Learner Posted September 14, 2011 Author Share Posted September 14, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/247111-using-_post-values-across-a-number-of-pages/#findComment-1269128 Share on other sites More sharing options...
cssfreakie Posted September 14, 2011 Share Posted September 14, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/247111-using-_post-values-across-a-number-of-pages/#findComment-1269170 Share on other sites More sharing options...
PHP Learner Posted September 14, 2011 Author Share Posted September 14, 2011 //Case closed echo Many thanks for your help. Cheers guys, L-plate Quote Link to comment https://forums.phpfreaks.com/topic/247111-using-_post-values-across-a-number-of-pages/#findComment-1269193 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.