session variable values are not being passed between pages
<p>i am a little new to php and although i have managed to pass values of session variables before this piece of code is leaving me puzzled</p>

<pre><code>&lt;form action="team_reg2.php" method="post" name="form1" class="cent" id="form1"&gt;
&lt;p&gt;&lt;strong&gt;Team Registration&lt;/strong&gt;&lt;/p&gt;
&lt;?php
    $con=mysql_connect("localhost","root","");
    mysql_select_db("databolism",$con);
    $result=mysql_query("select * from events where id=$_POST[event]",$con);
    $row=mysql_fetch_assoc($result);
    $num=$row['max_team'];
    $_SESSION['max_team']=$num;
    $_SESSION['event_id']=$_POST['event'];
    for($i=1;$i&lt;=$num;$i++)
    {
        print "&lt;p&gt;&lt;span id=\"sprytextfield$i\"\n&gt;";
        print "&lt;label&gt;member$i";
        print "&lt;input type=\"text\" name=\"mem$i\" id=\"mem$i\" /&gt;\n";
        print "&lt;/label&gt;\n";
        print "&lt;span class=\"textfieldInvalidFormatMsg\"&gt;Please enter only id&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;\n";
    }
?&gt;
</code></pre>

<p>now this will pass via post to team_reg2.php</p>

<pre><code>&lt;?php
    $con=mysql_connect("localhost","root","");
    if(!$con)
        die("could not connect to db");
    $db=mysql_select_db("databolism",$con);
    $num=6;
    $event=14;
    $result=mysql_query("select * from events where id=$event",$con) or die(mysql_error());
    $row=mysql_fetch_assoc($result);
    $query='fantasia1_'.$row['name'];
    $query2="select max(t_id) from $query";
    $que=mysql_query($query2,$con);
    $result=mysql_fetch_array($que) or die(mysql_error());
    $chk3=$result['max(t_id)']; 
    if($chk3==NULL)
    {
        for($i=1;$i&lt;=$num;$i++)
        {
            $name='mem'.$i;
            if($_POST["$name"]!="")
            {
                $query2="insert into $query values(1,'$_POST[$name]')";
                $que=mysql_query($query2,$con);
            }
        }

        echo " please note your team id is 1 &lt;br&gt;";
        echo " your team members are : &lt;br&gt;";
        for($i=1;$i&lt;=$num;$i++)
        {
            $name='mem'.$i;
            echo "$_POST[$name]&lt;br&gt;";
        }

    }
    else
    {
        $str="select * from $query where (";
        for($i=1;$i&lt;=$num;$i++)
        {
            $name='mem'.$i;
            $text="p_id='$_POST[$name]'";
            if($i==1)
                $str=$str.$text;
            else
                $str=$str.' or '.$text;
        }
        $str=$str.')'; 
        $query2=$str;
        echo "$str&lt;br&gt;";
        // echo "$query2&lt;/br&gt;";
        $que=mysql_query($query2,$con) or die(mysql_error());
        $num=mysql_num_rows($que);
        if($num!=0)
        {
            while($result=mysql_fetch_array($que))
            {
                echo "$result[p_id] is already registered in team $result[t_id]&lt;br&gt;";    
            }
            //include("reg_team.html");
        } 
        else if($num==0)
        {
            //echo $query;
            $query2="select max(t_id) from $query";
            $que=mysql_query($query2,$con) or die(mysql_error());
            //echo "$que&lt;br&gt;";
            $result=mysql_fetch_array($que);
            $max=$result['max(t_id)'];
            $max++;
            $num=$_SESSION['max_team'];
            for($i=1;$i&lt;=$num;$i++)
            {
                $name='mem'.$i;
                if($_POST[$name]!="")
                {
                    $query2="insert into $query values($max,'$_POST[$name]')";
                    $que=mysql_query($query2,$con);
                }
            }
            echo " please note your team id is $max &lt;br&gt;";
            echo " your team members are : &lt;br&gt;";
            for($i=1;$i&lt;=$num;$i++)
            {
                $name='mem'.$i;
                echo "$_POST[$name]&lt;br&gt;";
            }
        }
    }
?&gt;
</code></pre>

<p>i have done session_start(); at the beginning of the page itself. The problem is that echoing $_SESSION variables in second file is not printing anything.</p>

<p>someone please explain me whats going on.
thank you</p>
