Я использую PHP и возвращаю это значение: $_SESSION['sessionNum']
и получаю ошибку:
Notice: Undefined index: sessionNum.
Что означает эта ошибка?
Вот мой глючный PHP-код для ссылающейся страницы (create_session2.php)
<?php
session_start();
?>
<script type="text/javascript">
function validation() {
var isDataValid = true;
var sessionNoO = document.getElementById("sessionNo");
var errSessionNoMsgO = document.getElementById("sessionNoAlert")
if(sessionNoO.value == ""){
errSessionNoMsgO.innerHTML = "Please Set the Number of Sessions";
isDataValid = false;
}
else if (sessionNoO.value == 0){
errSessionNoMsgO.innerHTML = "Number of Sessions Must be More than 0";
isDataValid = false;
}
else {
errSessionNoMsgO.innerHTML = "";
}
return isDataValid;
}
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 your Session." +
"\n" + "\n" + "Are you sure you want to Proceed?" + "\n" );
if (confirmMsg==true){
submitform();
}
}
function submitform(){
var sessionFormO = document.getElementById("sessionForm");
sessionFormO.submit();
}
</script>
</head>
<body>
<h1>CREATING A NEW SESSION</h1>
<br/>
<form action="QandATable2.php"
method="post" id="sessionForm">
<p><strong> Number of Sessions you Require:</strong>
<input type="text"
id="sessionNo"
name="sessionNum"
onkeypress="return isNumberKey(event)"
maxlength="5" /><br/>
<span id="sessionNoAlert"></span>
</p>
<p><input class="questionBtn"
type="submit"
value="Prepare Questions"
name="prequestion" onClick="myClickHandler(); return false;"/>
</p>
<!-- Prepare Questions here-->
</form>
<script type="text/javascript">
function myClickHandler(){
if(validation()){
showConfirm();
}
}
</script>
</body>
Ниже приведен код для текущей страницы (QandATable2.php)
<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
session_start();
$outputDetails = "";
$outputDetails .= "
<table id='sessionDetails' border='1'>
<tr>
<th>Number of Sessions:</th>
<th>$_SESSION['sessionNum'] = $_POST['sessionNum'];</th>
</tr>";
$outputDetails .= " </table>";
echo $outputDetails;
?>