-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_room.php
30 lines (23 loc) · 1 KB
/
add_room.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
<?php
include_once ('dbcons.php');
//Accepting Form Add new data
$roomDetails = Array($_GET['roomID'], $_GET['roomName'], $_GET['roomDesc']);
/* Add data */
$querytester = "SELECT `room_num` FROM room_details WHERE `room_num` = '' ";
if(!empty($roomDetails))
{
$query = "INSERT INTO `room_details` (`room_num`, `room_name`, `room_desc`)
VALUES ('".$roomDetails[0]."', '".$roomDetails[1]."', '".$roomDetails[2]."') ";
mysqli_query($conn, $query);
if(mysqli_affected_rows($conn) > 0){
echo '<script>alert("Records inserted successfully."); </script>';
header("refresh:0; url = staff_page.php?id=update");
}
else{
if(mysqli_error($conn)){
echo '<script>alert("Failed to insert records!\nRoom ID already exists!"); window.location.replace(\'staff_page.php?id=update\');</script>';
}
}
}
mysqli_close($conn);
?>