Below I have an application. Now on the previous page user types in a number and submit the form into this page. The number is then displayed in this page. Now on this page the user submits the form to itself but the problem is that the number would then dissapear. How do I keep the number dispalyed after submitting the form to itself?
<?php
session_start();
//validate the post data if necessary
$_SESSION['sessionNum'] = $_POST['sessionNum'];
?>
<script type="text/javascript">
function showConfirm(){
var confirmMsg=confirm("Make sure that your details are correct, once you proceed after this stage you would not be able to go back and change any details towards Questions, Options and Answers for your Session." + "\n" + "\n" + "Are you sure you want to Proceed?" + "\n" );
if (confirmMsg==true)
{
submitform();
}
}
function submitform()
{
var sessionMarksO = document.getElementById("sessionMarks");
sessionMarksO.submit();
}
</script>
<body>
<form id="enter" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" onsubmit="return validateForm(this);" >
<p><input id="submitBtn" name="submitDetails" type="submit" value="Submit Details" onClick="myClickHandler(); return false;" /></p>
</form>
<script type="text/javascript">
function myClickHandler(){
if(validation()){
showConfirm();
}
}
</script>
<?php
$outputDetails = "";
$outputDetails .= "
<table id='sessionDetails' border='1'>
<tr>
<th>Number of Sessions:</th>
<th>$_SESSION['sessionNum']</th>
</tr>";
$outputDetails .= "</table>";
echo $outputDetails;
?>
Change :
to
this won’t reset the
sessionNumin the session unless you post a form with an input with the namesessionNum