Notice when using $_SESSION
<p>Below is my code. I am using <code>$_SESSION['sessionNum']</code> to get a value from a previous page and display it in the current page. Problem is though is that it is giving me a notice in the current page stating: </p>

<pre><code>Notice: Undefined index: sessionNum. 
</code></pre>

<p>This is the $_SESSION['sessionNum'] line. What I want to is the notice to disappear and that the number would be displayed on the page. Also if I use <code>$_SESSION['sessionNUm']</code>, does that mean that if I submit the current form to itself, that that the number will still be displayed on the page or will it disappear?</p>

<p>If you click on this <a href="https://helios.hud.ac.uk/u0867587/Mobile_app/create_session2.php" rel="nofollow">link</a>, it will take you to the hmtl page of the previous page. Type in a number in the textbox then submit the form,  after confirmation you will come up onto the current page I am trying to fix and this is where I am getting the notice.</p>

<p>Thank you           </p>

<p>Below is code for the previous page (create_session2.php)</p>

<pre><code>                &lt;?php

            session_start();

        ?&gt;

        &lt;script type="text/javascript"&gt;



 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();

            }


        &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;


    &lt;h1&gt;CREATING A NEW SESSION&lt;/h1&gt;


        &lt;br/&gt;

         &lt;form action="QandATable2.php" method="post" id="sessionForm"&gt;
          &lt;p&gt;&lt;strong&gt; Number of Sessions you Require:&lt;/strong&gt; &lt;input type="text" id="sessionNo" name="sessionNum" onkeypress="return isNumberKey(event)" maxlength="5" /&gt;&lt;br/&gt;&lt;span id="sessionNoAlert"&gt;&lt;/span&gt;&lt;/p&gt;
            &lt;p&gt;&lt;input class="questionBtn" type="submit" value="Prepare Questions" name="prequestion" onClick="myClickHandler(); return false;"/&gt;&lt;/p&gt;      &lt;!-- Prepare Questions here--&gt;

        &lt;/form&gt;

         &lt;script type="text/javascript"&gt;

function myClickHandler(){ 
     if(validation()){ 
                showConfirm(); 
     } 
}


&lt;/script&gt;

    &lt;/body&gt;
</code></pre>

<p>Below is code for the current page (QandATable2.php)</p>

<pre><code>   &lt;script type="text/javascript"&gt;

             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();

            }

            &lt;/script&gt;


&lt;body&gt;

      &lt;form id="enter" action="&lt;?php echo htmlentities($_SERVER['PHP_SELF']); ?&gt;" method="post" onsubmit="return validateForm(this);" &gt;
        &lt;p&gt;&lt;input id="submitBtn" name="submitDetails" type="submit" value="Submit Details" onClick="myClickHandler(); return false;" /&gt;&lt;/p&gt;
        &lt;/form&gt; 


         &lt;script type="text/javascript"&gt;

    function myClickHandler(){
         if(validation()){
                    showConfirm();
         }
    }

&lt;/script&gt;

    &lt;?php

    session_start();

    $outputDetails = "";
    $outputDetails .= "
    &lt;table id='sessionDetails' border='1'&gt;
    &lt;tr&gt;
    &lt;th&gt;Number of Sessions:&lt;/th&gt; 
    &lt;th&gt;$_SESSION['sessionNum'] = $_POST['sessionNum'];&lt;/th&gt;
    &lt;/tr&gt;";
    $outputDetails .= "        &lt;/table&gt;";

    echo $outputDetails;


    ?&gt; 
</code></pre>
