/
name.php
58 lines (39 loc) · 1.16 KB
/
name.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
<?php
session_start();
$connect = mysqli_connect("localhost", "root", "", "wtproject");
if ($_POST["ac"]=='Yes'){
$ac = "Yes";
}
else {
$ac = "No";
}
if($_POST["roomtype"]=='SINGLE'){
$rType="SINGLE";
}
else if($_POST["roomtype"]=='DOUBLE'){
$rType="DOUBLE";
}
else if($_POST["roomtype"]=='FAMILY'){
$rType="DOUBLE";
}
else if($_POST["roomtype"]=='MULTIPORPOSES'){
$rType="MULTIPORPOSES";
}
$number = count($_POST["name"]);
if($number > 0)
{
for($i=0; $i<$number; $i++)
{
if(trim($_POST["name"][$i] != ''))
{
$sql = "INSERT INTO hotel_room(h_name,r_type,r_no, ac, r_cost, r_pic) VALUES('".mysqli_real_escape_string($connect, $_SESSION['hotel'])."','".mysqli_real_escape_string($connect, $rType)."','".mysqli_real_escape_string($connect, $_POST["name"][$i])."', '".mysqli_real_escape_string($connect, $ac)."', '".mysqli_real_escape_string($connect, $_POST["cost"][$i])."', '".mysqli_real_escape_string($connect, $_POST["fileToUpload"][$i])."')";
mysqli_query($connect, $sql);
}
}
echo "Data Inserted";
}
else
{
echo "Please Enter Name";
}
?>