0

I need to construct booking system for cinema. I choose PHP and MySQL.

On the first booking page user is supposed to write his name etc. and choose a movie. The .php page will redirect him to a page with specified movie hours based on his choice and on this page user need to choose time that he wants to pop in.

The problem is that I can't update previously added row, after user choice an hour whole new row is added. Could you help me find the right answer to this problem?

HTML FORM Booking

        <!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 booking 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 hours

<?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')");

?>

halfer
  • 19,824
  • 17
  • 99
  • 186
Lixi
  • 142
  • 1
  • 9

0 Answers0