I have two pages that i like to exchange variable. in the first page i have form like this:
<form method='post' action='rehabCreate2.php' onsubmit='return validateForm();'>
<input class="textbox" type='text' id='txt_stuNum' name='txt_stuNum'/ required>
<input type="submit" value="NEXT" id="btnNext">
</form>
then i set the session variable like this:
if ( isset( $_POST['btnNext'])){
$stuId=$_POST['txt_stuNum'];
$_SESSION["stuId"]=$stuId;
}
then in my page2 i want to it:
<?php
session_start();
$stuId=$_SESSION["stuId"];
echo $stuId;
?>
but it gives me error:
Notice: Undefined index: stuId in...
what am i missing? and another thing, how can i make a "back button" and the values are still in there?
EDIT: originally my "session_start()" was place at the top of the page1, but when i transfer it below my "" this error message show: Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\cerecare\portal\somepage.php:176) in C:\xampp\htdocs\cerecare\portal\rehabCreate.php on line 16
by the way: the line 176 of somepage is the end of the script tag and nothing else follows
session_start();in your$_POSTprocessing page?session_start()?