Jump to content

passing data from one page to another


jacko310592

Recommended Posts

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

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?

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

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.