My problem is the session won't carry over (i.e. display on the second screen). I've tried putting the session variables into $low and $high variables but it still won't work. Anyone know what i'm doing wrong or lead me in the right direction? Here's my code (within the body tags):
<form method="post">
<?php
session_start();
$nextstep=$_POST['nextstep'];
if(!$nextstep||$nextstep=='NEXT DRAW')
{
$_SESSION['rand1']=rand(1,14);
$_SESSION['rand2']=rand($_SESSION['rand1'],14);
$low=$_SESSION['rand1'];
$high=$_SESSION['rand2'];
?>
<h1>Screen 1</h1><br />
Low Card: <?php print $_SESSION['rand1']; ?><br /><br />
High Card: <?php print $_SESSION['rand2']; ?><br /><br />
<input type="submit" value="BET" name="nextstep" />
<input type="submit" value="PASS" name="nextstep" /><?php
}
if($nextstep=='BET')
{
$guess=rand(1,14);
if($guess>=$_SESSION['rand1']&&$guess<=$_SESSION['rand2'])
{
?><h1>Screen 2</h1><br />
Low Card: <?php print $low;?><br /><br />
High Card: <?php print $high;?><br /><br />
Target: <?php print $guess; ?><br />
<?php print "Yes!";
}
else
{
?><h1>Screen 2</h1><br />
Low Card: <?php print $low;?><br /><br />
High Card: <?php print $high;?><br /><br />
Target: <?php print $guess; ?><br />
<br /><?php print "You Lose!";
}
?><br /><input type="submit" value="NEXT DRAW" name="nextstep" /><?php
}
else if($nextstep=='PASS')
{
$_SESSION['rand1']=rand(1,14);
$_SESSION['rand2']=rand($_SESSION['rand1'],14);
?>
<h1>Screen 1</h1><br />
Low Card: <?php print $_SESSION['rand1']; ?><br /><br />
High Card: <?php print $_SESSION['rand2']; ?><br /><br />
<input type="submit" value="BET" name="nextstep" />
<input type="submit" value="PASS" name="nextstep" /><?php
}
?>

New Topic/Question
Reply



MultiQuote




|