-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuser_home.php
152 lines (136 loc) · 5.41 KB
/
user_home.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!--
File Name: user_home.php
Author's Name: Sukhdeep Singh, Nav Bhullar
Web Site Name: Tourney Bracket
File Description: This page is the first page when the user loggs into the Site which Gives the user options to Logout, Create a new tournament, or Modify the existing tournaments
-->
<?php
//access current session
session_start();
//evaluate the user_id stored in the session that was set on validate.php
if (empty($_SESSION['user_id'])) {
header('Location:index.php');
}
else {
$conn = mysqli_connect('webdesign4', 'dbxxxxxxxxx', 'xxxxx', 'dbxxxxxxxxx') or die('Error connecting to MySQL server');
$userID = $_SESSION['user_id'];
$sql = "SELECT email,username FROM tourney_admins where id = $userID";
$email = mysqli_query($conn, $sql);
while ($address = mysqli_fetch_array($email)) {
$emailAddress = $address['email'];
$user = $address['username'];
}
mysqli_close($conn);
require_once 'header.php';
?>
<h1>Welcome <?php echo $user; ?>!</h1>;
<hr class="featurette-divider">
<!--Logout Button-->
<a href="logout.php" role="button" class="btn btn-primary btn-lg">Logout</a>
<hr class="featurette-divider">
<!--Modify Existing Button-->
<button class="btn btn-primary btn-lg pull-right" data-toggle="modal" data-target="#tournamentModal">
Modify Existing
</button>
<!--Create New Tournament Form-->
<h1>Create a New Tournament</h1>
<hr class="featurette-divider">
<form class="form-horizontal" role="form" method="post" action="create_tournament.php">
<div class="form-group">
<label for="tourname" class="col-sm-2 control-label">Tournament Name</label>
<div class="col-sm-10">
<input type="text" name="tourname" class="form-control" id="tourname" placeholder="Tournament Name" required="">
</div>
</div>
<div class="form-group">
<label for="desc" class="col-sm-2 control-label">Short Description</label>
<div class="col-sm-10">
<input type="text" name="desc" class="form-control" id="desc" placeholder="Description" required="">
</div>
</div>
<hr class="featurette-divider">
<div class="form-group">
<label for="player1" class="col-sm-2 control-label">Player Name</label>
<div class="col-sm-10">
<input type="text" name="player1" class="form-control" id="player1" placeholder="1st Player Name" required="">
</div>
</div>
<div class="form-group">
<label for="player2" class="col-sm-2 control-label">Player Name</label>
<div class="col-sm-10">
<input type="text" name="player2" class="form-control" id="player2" placeholder="2nd Player Name" required="">
</div>
</div>
<div class="form-group">
<label for="player3" class="col-sm-2 control-label">Player Name</label>
<div class="col-sm-10">
<input type="text" name="player3" class="form-control" id="player3" placeholder="3rd Player Name" required="">
</div>
</div>
<div class="form-group">
<label for="player4" class="col-sm-2 control-label">Player Name</label>
<div class="col-sm-10">
<input type="text" name="player4" class="form-control" id="player4" placeholder="4th Player Name" required="">
</div>
</div>
<div class="form-group">
<label for="player5" class="col-sm-2 control-label">Player Name</label>
<div class="col-sm-10">
<input type="text" name="player5" class="form-control" id="player5" placeholder="5th Player Name" required="">
</div>
</div>
<div class="form-group">
<label for="player6" class="col-sm-2 control-label">Player Name</label>
<div class="col-sm-10">
<input type="text" name="player6" class="form-control" id="player6" placeholder="6th Player Name" required="">
</div>
</div>
<div class="form-group">
<label for="player7" class="col-sm-2 control-label">Player Name</label>
<div class="col-sm-10">
<input type="text" name="player7" class="form-control" id="player7" placeholder="7th Player Name" required="">
</div>
</div>
<div class="form-group">
<label for="player8" class="col-sm-2 control-label">Player Name</label>
<div class="col-sm-10">
<input type="text" name="player8" class="form-control" id="player8" placeholder="8th Player Name" required="">
</div>
</div>
<input type="hidden" name="ownername" value="<?php echo $user ?>">
<input type="hidden" name="owneremail" value="<?php echo $emailAddress ?>">
<hr class="featurette-divider">
<button type="submit" class="btn btn-primary btn-lg btn-block">
Create & Activate
</button>
</form>
<hr class="featurette-divider">
<!-- Existing Tournaments Modal -->
<div class="modal fade" id="tournamentModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title" id="myModalLabel">Choose Tournament</h4>
</div>
<div class="modal-body">
<?php
$conn = mysqli_connect('webdesign4', 'db200245935', '37949', 'db200245935') or die('Error connecting to MySQL server');
$query = 'SELECT id,tourname FROM `tournaments` where `owneremail` = "'.$emailAddress.'"';
$tournaments = mysqli_query($conn, $query);
while ($row = mysqli_fetch_array($tournaments))
{
echo'<a href="Modify.php?id='.$row['id'].'" role="button" class="btn btn-primary btn-lg">'.$row['tourname'] .'</a>';
}
mysqli_close($conn);
?>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<?php
}
require_once 'footer.php';
?>