使用会话变量确定表单操作时,不加载Php页面

时间:2013-02-06 08:07:20

标签: php session variables

我对表格比较陌生,如果我在发帖时出错,很抱歉。

<?php

require_once("login/include/membersite_config.php");

if(!$fgmembersite->CheckLogin())
{
    $fgmembersite->RedirectToURL("./login/login.php");
    exit;
}

include 'menu.php';

$is_student = $_POST["is_student"];

//echo "<br/> student $is_student <br/>";

?>

<html>
<head>
<title>Seat Selection</title>
<link href="xampp.css" rel="stylesheet" type="text/css">
</head>

<body>
<h1>
<?php
if ($is_student == "no") {
  $student = FALSE;
  $_SESSION['student'] = FALSE;
} elseif ($is_student == "yes") {
  $student = TRUE;
  $_SESSION['student'] = TRUE;
} else {
  echo "Please select Student or Parent before making reservation.";
  die();
}

if ($student)
  echo "Student Reservation";
else
  echo "Parent Reservation";

?>
</h1>
<h2>Step 1 of 2: Select Seats</h2>

<table>

<?php if ($student) { ?>
  <form name="seats" action="confirms.php" method="POST">
<?php } else { ?>
  <form name="seats" action="confirm.php" method="POST">
<?php } ?>

<?php


        $all_seats = $fgmembersite->GetAllSeats($student); // it's a 2 dimensional array $list[row][col]
                                               // the value of which is another array with seatid and whether it's
                                               // filled or not
        $reserved_seats = $fgmembersite->GetAllReservedSeats($student);

        //var_dump($reserved_seats);

        // merge the reserved seats into all seats
        foreach ($reserved_seats as $r => $arr) {
          //echo "R =$r <br/>";
          //var_dump($arr);
          foreach($arr as $c => $seatid) {
             //echo "R = $r, C = $c, S = $seatid><br/>";
            $all_seats[$r][$c] = array(seatid => $seatid, filled => TRUE);
          }
        }

        foreach ($all_seats as $r => $c) {
          echo $r. ">";
          foreach ($c as $value) {
            if ($value['filled']) {
              echo "x";
               } else {
              echo "<input type=\"checkbox\" name=\"seats[]\" value=\"$value[seatid]\"/>";
            }
          }
          echo "<br/>";
        }
?>

<input type="Submit" name="SeatsSelected" value="Select Seats">
</form>
</table>

</body>
</html>

我正在尝试使用来自$ student的布尔值来确定它转到哪个确认页面,但是当我加载文件代码在(seat.php)中时,它不会加载。它的作用类似于Web目录中缺少的页面。知道怎么了?这可能只是我糟糕的编码。

1 个答案:

答案 0 :(得分:0)

试试这个:

<?php if ($student) { ?>
  <form name="seats" action="confirm.php" method="POST"> 
<?php } else { ?>
  <form name="seats" action="confirms.php" method="POST"> 
<?php } ?>