I get notices for all of the $_POST's I have
<p>I have a couple of pages in my application. In the first page (create_session.php) which is below the user submits the form and goes onto the next page (QandATable.php).</p>

<pre><code>&lt;form action="QandATable.php" method="post" id="sessionForm"&gt;

&lt;p&gt;
    &lt;strong&gt;
        Your Session ID: 
    &lt;/strong&gt;
    &lt;span id="idFont"&gt;
        &lt;?php echo $id; ?&gt;
    &lt;/span&gt;
&lt;/p&gt;
&lt;input type="hidden" name="id" value="&lt;?php echo $id; ?&gt;" /&gt;

&lt;p&gt;
    &lt;strong&gt;
        Date:
    &lt;/strong&gt; 
    &lt;input type="text" id="datepicker" name="dateChosen" readonly="readonly" /&gt;
&lt;p&gt;
    &lt;strong&gt;
        Start Time:
    &lt;/strong&gt; 
    &lt;input type="text" id="timepicker" name="timeChosen" readonly="readonly" /&gt;

&lt;p&gt;
    &lt;input class="questionBtn" type="submit" value="Prepare Questions" name="prequestion"/&gt;
&lt;/p&gt; 

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

<p>Now if $_POST['id'] equals 1, then there is only 1 exam, but if it it is more than 1, then there are multiple exams which is where the problem occurs.</p>

<p>Lets say I wanted 2 exams and I submit the form to the QandATable.php, then the first exam has no problems, but after I finish the first exam and then submit the form (This form would submit to itself), then for the second exam, I suddenly get notices for all of the $_POST I have in the code below.</p>

<pre><code>&lt;?php
session_start();

if (isset($_POST['id'])) 
{
    $_SESSION['id'] = $_POST['id'];
}


if (isset($_POST['dateChosen'])) 
{
    $_SESSION['dateChosen'] = $_POST['dateChosen'];
}

if (isset($_POST['timeChosen'])) 
{
    $_SESSION['timeChosen'] = $_POST['timeChosen'];
}

$username="xxx";
$password="xxx";
$database="xxx";

mysql_connect('localhost',$username,$password);

mysql_select_db($database) or die( "Unable to select database");

$insert = array();

for ($i = 1, $n = $_POST['sessionNum']; $i &lt;= $n; ++$i)
{
    $insert[] = "' ". mysql_real_escape_string( $_POST['id'] ) . ($n == 1 ? '' : $i) . "',' ". mysql_real_escape_string( $_POST['timeChosen'] ) . "',' ". mysql_real_escape_string( date("Y-m-d", strtotime( $_POST['dateChosen'] ) ) ) . "'";
}

$sql = "INSERT INTO Session (SessionId, SessionTime, SessionDate) 
VALUES (" . implode('), (', $insert) . ")";

mysql_query($sql);
mysql_close();    
?&gt;
</code></pre>

<p>So what I want to know is that when I have multiple exams, why am I getting notices on all of the $_POST's after the first exam has been completed? All the notices are undefined indexes on all the posts. </p>
