I have a form website (in htm) that works fine, pressing send button displays everything fine on page 2. Problem is I want to keep that info so the user can print the results on a different page (page 3) but the data is lost.
I found out after searching all over the internet (php session tutorial) the best way to do this is with sessions. A couple of questions if I may:
The following example uses three pages called page1.php. page2.php and page3.php
page1.php
<?php
session_start();
if($POST['button']){
$SESSION['name'] = $_POST['name'];
session_write_close();
echo 'Session has been saved<a href="page2.php"> Go to page2.php</a>';
}else{
?>
<form name="form1" method="post" action="">
<label>
Enter Name:
<input name="name" type="text" id="textarea" value="" size="20" maxlength="20">
</label>
<br>
<label>
<input type="submit" name="button" id="button" value="Submit">
</label>
</form>
<?php
}
?>
page2.php
<?php
session_start();
echo 'this is page2.php. <br> $SESSION['name'] is equals to: '.$SESSION['name'];
?>
Page2.php causes an error I can't seem to figure out:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/content/c/o/t/cottoneye1256/html/page2.php on line 3
Please help I'm going nuts trying to figure out sessions
Thank you