session variable values are not being passed between pages

Posted by ravi nankani on Stack Overflow See other posts from Stack Overflow or by ravi nankani
Published on 2010-04-25T11:40:32Z Indexed on 2010/04/25 11:43 UTC
Read the original article Hit count: 173

Filed under:

hi, 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

<form action="team_reg2.php" method="post" name="form1" class="cent" id="form1">

Team Registration

"; print "member$i"; print "\n"; print "\n"; print "Please enter only id

\n"; } ?> now this will pass via post to team_reg2.php

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

} else {

$str="select * from $query where ("; for($i=1;$i<=$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
"; // echo "$query2"; $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]
";
} //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
"; $result=mysql_fetch_array($que); $max=$result['max(t_id)']; $max++; $num=$_SESSION['max_team']; for($i=1;$i<=$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
"; echo " your team members are :
"; for($i=1;$i<=$num;$i++) { $name='mem'.$i; echo "$_POST[$name]
"; }

}

} ?>

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.

someone please explain me whats going on. thank you

© Stack Overflow or respective owner

Related posts about php