-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclaim.php
More file actions
34 lines (29 loc) · 1008 Bytes
/
claim.php
File metadata and controls
34 lines (29 loc) · 1008 Bytes
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
<?php
session_start();
$room = $_REQUEST['room'];
if(strlen($room)>20 or strlen($room)<2){
echo "<script>alert('please enter size of room between 3 and 20')</script>";
echo "<script>location.href='index.php';</script>";
}
else if(!ctype_alnum($room)) {
echo "<script>alert('please enter alphanumeric room name')</script>";
echo "<script>location.href='index.php';</script>";
}
else{
include('dbcon.php');
$sql = "SELECT * FROM rooms where roomname = '$room'";
$result = $conn->query($sql);
if($result->num_rows >0){
echo "<script>alert('room already occupied')</script>";
echo "<script>location.href='index.php';</script>";
}
else{
$sql1 = "INSERT INTO rooms (roomname,stime) VALUES('$room',CURRENT_TIMESTAMP)";
$result1 = $conn->query($sql1);
if($result1){
echo "<script>alert('room claimed')</script>";
echo "<script>location.href='room.php?roomname=".$room."';</script>";
}
}
}
?>