forked from mog3n/csgo-bet-manager
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnewroom.php
107 lines (86 loc) · 3.72 KB
/
newroom.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
include 'database.php';
session_start();
if(!isset($_SESSION['username'])){
header('Location: index.php');
}
if(isset($_POST['roomname'])){
$roomname = stripslashes(strip_tags($_POST['roomname']));
}
if(isset($_POST['description'])){
$description = stripslashes(strip_tags($_POST['description']));
}
if(isset($_POST['startingamount'])){
$startingamount = stripslashes(strip_tags($_POST['startingamount']));
}
if(isset($_POST['roomname']) && isset($_POST['description']) && isset($_POST['startingamount'])){
$createconn = $conn->prepare('INSERT INTO rooms (owner, name, description, date, start_amount) VALUES (?, ?, ?, ? ,?)');
$createconn->bindParam(1, $_SESSION['username']);
$createconn->bindParam(2, $roomname);
$createconn->bindParam(3, $description);
$createtime = time();
$createconn->bindParam(4, $createtime);
$createconn->bindParam(5, $startingamount);
if($createconn->execute()){
//done
//$findroomconn = $conn->prepare('SELECT id FROM rooms WHERE owner=? SORT BY date DESC');
//$findroomconn->bindParam(1, $_SESSION['username']);
//$findroomconn->execute();
//$idresults = $findroomconn->fetchAll();
//foreach($idresults as $room){
//header('Location: room.php?id=' . $room['id']); //redirect to room id
//}
header('Location: betting.php');
}else{
echo 'did not execute stmt';
echo $_SESSION['username'] . $roomname . $description . $startingamount;
}
}else{
if(isset($roomname)){ echo 'missing values $roomname, $description, $startingamount'; }
}
?>
<html>
<head>
<title>Mog's Betting</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.4/css/bootstrap.min.css">
<link rel="stylesheet" href="styles.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
</head>
<body>
<div class="container">
<div class="roomheader">
<span><a href="index.php" class="list-group-item active">Mog's CSGO</a></span>
</div>
<div class="jumbotron">
<h1 class="display-1">Create a bet room</h1>
<div align="left"><?php if(isset($_SESSION['username'])){ echo 'Signed in as '.$_SESSION['username'] . ' <a href="logout.php">Logout</a>'; }
else{
echo '<div align="right"><a href="login.php">Login</a></div>';
} ?></div>
<form action="newroom.php" method="POST">
<div class="input-group" style="padding-top: 10px">
<div class="input-group input-group-lg">
<span class="input-group-addon" id="sizing-addon1">@</span>
<input type="text" name="roomname" class="form-control" placeholder="Room name">
</div>
<div class="input-group"><br>
<input type="text" class="form-control" name="description" placeholder="Description">
</div><br>
<div class="input-group input-group-lg">
<span class="input-group-addon" id="sizing-addon1">$</span>
<input type="text" class="form-control" name="startingamount" placeholder="Starting amount">
</div><br>
<div class="input-group">
<button type="submit" class="btn btn-outline-primary btn-lg">Create</button>
</div>
</div>
</form>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js" integrity="sha384-THPy051/pYDQGanwU6poAc/hOdQxjnOEXzbT+OuUAFqNqFjL+4IGLBgCJC3ZOShY" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.2.0/js/tether.min.js" integrity="sha384-Plbmg8JY28KFelvJVai01l8WyZzrYWG825m+cZ0eDDS1f7d/js6ikvy1+X+guPIB" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.4/js/bootstrap.min.js" integrity="sha384-VjEeINv9OSwtWFLAtmc4JCtEJXXBub00gtSnszmspDLCtC0I4z4nqz7rEFbIZLLU" crossorigin="anonymous"></script>
</body>
</html>