-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reservephp.php
60 lines (56 loc) · 1.52 KB
/
Reservephp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
session_start();
$name=$_POST['EventName'];
$seats=$_POST["NoSeats"];
$arr=array();
for ($i=1; $i < $seats+1; $i++)
{
if (isset($_POST['checkbox'.$i]))
{
break;
}
else if($i == $seats)
{
echo '<script type="text/javascript">
window.onload = function () { alert("No seat selected"); }
</script>';
echo "<script>setTimeout(\"location.href = 'Calendar.php';\",0);</script>";
exit();
}
}
$con=mysql_connect("localhost", "root", "");
if (!$con) {
die('could not connect: '.mysql_error());
}
mysql_select_db("opera", $con);
$q="SELECT MAX(rid) AS rid FROM reservation;";
$r=mysql_query($q, $con);
$m=mysql_fetch_array($r);
$max=$m['rid']+1;
$q="insert into reservation(`rid`, `eno`, `cust`) values(".$max.", ".$name.", '".$_SESSION['uname']."')";
$r=mysql_query($q, $con);
if($r)
{
for ($i=1; $i < $seats+1; $i++)
{
if (isset($_POST['checkbox'.$i]))
{
$q="insert into seat_reserved(`rid`, `sno`, `hno`) Values(".$max.", ".$i.",".$_POST['hno'].")";
$r=mysql_query($q, $con);
}
}
echo '<script type="text/javascript">
window.onload = function () { alert("Seats Reserved. Your ReservationID is '.$max.'"); }
</script>';
echo "<script>setTimeout(\"location.href = 'Calendar.php';\",0);</script>";
exit();
}
else
{
echo '<script type="text/javascript">
window.onload = function () { alert("Error Reserving seat. Please try again later"); }
</script>';
echo "<script>setTimeout(\"location.href = 'Calendar.php';\",0);</script>";
exit();
}
?>