0

不知道为什么 book.php 中没有响应,使用 flight.php 中的 post 方法和表单: 这里是 flight.php:

<?php
$host="127.0.0.1"; 
$username="test"; 
$password="";  
$db_name="test_db"; 
$tbl_name="Customer_Login"; 
$con = mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
$time_now = time(); 
$date_now = date("y-m-d");
$exec1="select * from Flight where '".$date_now."' < Flight.Date OR '".$date_now."' = Flight.Date AND '".$time_now."' < Flight.Departure_Time;"; 
if($result1=mysql_query($exec1)) 
{  
    echo "<form action=\"book.php\" method=\"post\" name=\"bookflight\">";
    echo "<tr class=\"fdbg\"><td colspan=\"2\"><div align=\"right\" style = \"padding-right:220px\"><input type=\"submit\" name=\"Submit\" value=\"Book\"></div></td></tr>";
    echo "<table align = \"center\" border=\"1\" cellspacing=\"5\"><tr><td align=\"center\">Flight No.</td><td align=\"center\">Date</td><td align=\"center\">Depature Time</td>";
    echo "<td align=\"center\">Arrival Time</td><td align=\"center\">Depature City</td><td align=\"center\">Arrival City</td><td align=\"center\">Capacity</td><td align=\"center\">Price</td><td align=\"center\">Choose</td></tr>";
    while($row = mysql_fetch_array($result1))
    {
        echo "<tr>";
        echo "<td align=\"center\">";
        echo $row['Flight_No'];
        echo "</td>";
        echo "<td align=\"center\">";
        echo $row['Date'];
        echo "</td>";
        echo "<td align=\"center\">";
        echo $row['Departure_Time'];
        echo "</td>";
        echo "<td align=\"center\">";
        echo $row['Arrival_Time'];
        echo "</td>";
        echo "<td align=\"center\">";
        echo $row['Departure_City'];
        echo "</td>";
        echo "<td align=\"center\">";
        echo $row['Arrival_City'];
        echo "</td>";
        echo "<td align=\"center\">";
        echo $row['Capacity'];
        echo "</td>";
        echo "<td align=\"center\">";
        echo $row['Price'];
        echo "</td>";
        echo "<td align=\"center\"><input type=\"radio\" name=\"flight[]\" value=\"";
        echo $row['FID'];
        echo "\"/></td>";
        echo "</tr>";
    }
    echo "</table>";
    echo "<tr class=\"fdbg\"><td colspan=\"2\"><div align=\"right\" style = \"padding-right:220px\"><input type=\"submit\" name=\"Submit\" value=\"Book\"></div></td></tr>";
    echo "</form>";
} 
else 
{ 
    echo "<script>alert('Database Connection Error!');location.href='welcome.php';</script>"; 
} 
mysql_free_result($result1);
mysql_close($con);
?>

还有book.php,点击flight.php中的按钮没有反应

<?php
session_start();
if(!isset( $_SESSION['username'])){
header("location:index.php");
}
$host="127.0.0.1";  
$username="test"; 
$password="";  
$db_name="test"; 

$con = mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$CID = $_SESSION['username'];
$FID = $_POST['flight[]'];
$time_now = date("y-m-d h:i:s");

echo "<script>alert('2');</script>";
echo "<script>alert('".$FID."');</script>";
echo "<script>alert('".$time_now."')</script>;";

$exec = "call BOOK_FLIGHT('".$CID."','".$FID."','".$time_now."');"; //call BOOK_FLIGHT('$CID','$FID','$time_now')
$result = mysql_query($exec);
print $result;
$result1 = mysql_query("call INSERT_RESULT('".$result."');");
echo "alert('".$result1."')";

mysql_close($con);
header("location:flight.php");
?>

我使用mysql中的程序,在我直接测试后可以正常工作。我相信我的 php 代码有问题。任何人都可以为我指出吗?非常感谢您的帮助。

4

0 回答 0