jacko310592 Posted December 2, 2009 Share Posted December 2, 2009 hey guys i have the follwoing code to get information from one page and place on another: (1st page) page to get info from: <?php session_start(); $_SESSION['data'] = "blah blah blah"; ?> (2nd page) page to show info on: <?php session_start(); $data= $_SESSION['data'];?> // at top of page <?php echo $data; ?> i would like to use this code to show an error report, but the thing is that once the information has been called on the second page it stays there, i would like it so if the page is reloaded the info will be reset/not show until the 1st page is loaded again. can anyone help me please? thanks everyone Link to comment https://forums.phpfreaks.com/topic/183737-passing-data-from-one-page-to-another/ Share on other sites More sharing options...
rajivgonsalves Posted December 2, 2009 Share Posted December 2, 2009 use the unset function for that var on the second page http://php.net/manual/en/function.unset.php Link to comment https://forums.phpfreaks.com/topic/183737-passing-data-from-one-page-to-another/#findComment-969767 Share on other sites More sharing options...
jacko310592 Posted December 2, 2009 Author Share Posted December 2, 2009 asuming ive done this the way you ment (which i probs havnt), it didnt work :/ it just stops it from showing all together <?php session_start(); $data= $_SESSION['data'];?> <?php unset($data); echo $data; ?> any suggestions or corrections? Link to comment https://forums.phpfreaks.com/topic/183737-passing-data-from-one-page-to-another/#findComment-969776 Share on other sites More sharing options...
rajivgonsalves Posted December 2, 2009 Share Posted December 2, 2009 where is $captchaIncorrect defined on page two ? if its in $_SESSION['data'] then unset($_SESSION['data']['captchaIncorrect']); Link to comment https://forums.phpfreaks.com/topic/183737-passing-data-from-one-page-to-another/#findComment-969777 Share on other sites More sharing options...
jacko310592 Posted December 2, 2009 Author Share Posted December 2, 2009 sorry about that, coppied the wrong names then XD thats another that i was also doing. so would that become <?php session_start(); $data= unset($_SESSION['data']);?> <?php echo $data; ?> if so, that gives me the following error: Parse error: syntax error, unexpected T_UNSET in http://mysite.com/index.php on line 33 which is refaring to line "$data= unset($_SESSION['data']);?>" thanks for the replies by the way Link to comment https://forums.phpfreaks.com/topic/183737-passing-data-from-one-page-to-another/#findComment-969783 Share on other sites More sharing options...
rajivgonsalves Posted December 2, 2009 Share Posted December 2, 2009 <?php session_start(); $data= $_SESSION['data']; unset($_SESSION['data']); ?> <?php echo $data; ?> Link to comment https://forums.phpfreaks.com/topic/183737-passing-data-from-one-page-to-another/#findComment-969791 Share on other sites More sharing options...
jacko310592 Posted December 2, 2009 Author Share Posted December 2, 2009 thanks allot rajivgonsalves, works perfectly now (: Link to comment https://forums.phpfreaks.com/topic/183737-passing-data-from-one-page-to-another/#findComment-969793 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.