我需要建立电影预订系统。我选择PHP和MySQL。
在第一个预订页面上,用户应该写下他的名字等并选择一部电影。 .php页面会根据他的选择将他重定向到指定电影小时的页面 在此页面上,用户需要选择他想要弹出的时间。
问题在于,在用户选择一小时全新行添加后,我无法更新以前添加的行。你能帮我找到解决这个问题的正确答案吗?
HTML FORM预订
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Book it</title>
</head>
<body>
<form action="book.php" method="POST">
Firstname<br />
<input type="text" name="Firstname" /><br />
Secondname<br/>
<input type="text" name="Secondname" /><br />
Number of party:<br/>
<input type="number" name="Quantity" /><br />
E-mail:<br />
<input type="text" name="Email" /><br />
<!--Date:<br/>
<input type="text" name="Date" /><br />-->
<select name="Movie">
<option value="1">Dark Knight</option>
<option value="5">Wolverine</option>
<option value="6">The Pianist</option>
< option value="7">Fifth Estate</option>
</select>
<input type="submit" value="Book it" />
</form>
</body>
</html>
PHP bookit
<?php
$Firstname = $_POST['Firstname'];
$Secondname = $_POST['Secondname'];
$Quantity = $_POST['Quantity'];
$Movie = is_numeric($_POST['Movie']);
$Email = $_POST['Email'];
/** connecting to DB */
$connection = mysql_connect('localhost', 'root', '');
mysql_select_db('cinema', $connection);
/** adding record to table*/
$ins = @mysql_query("INSERT INTO booking (Firstname, Secondname, Quantity, Email, MovieID) VALUES ('$Firstname','$Secondname','$Quantity', '$Email','$MovieID')");
switch ($Movie)
{
case "1":
header("Refresh: 1; url=darknighth.html");
break;
case "5":
header("Refresh: 1; url=wolverineh.html");
break;
case "6":
header("Refresh: 1; url=pianisth.html");
break;
case "7":
header("Refresh: 1; url=fifthestateh.html");
break;
default:
echo "Ops something went wrong try agian";
}
?>
PHP预订wolverine
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form action="hours.php" method="POST">
<select name="Time">
<option value="16">16:00</option>
<option value="20">20:00</option>
<option value="21">21:00</option>
</select>
<input type="submit" value="Book it" />
</form>
</body>
</html>
PHP小时
<?php
/** connecting to DB */
$connection = mysql_connect('localhost', 'root','');
mysql_select_db('cinema',$connection);
$Time = $_POST['Time'];
$MovieInt = (int)$Time;
$ins = @mysql_query("INSERT INTO booking (Time) VALUES ('$MovieInt')");
&GT;