-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostevent.php
57 lines (50 loc) · 1.6 KB
/
postevent.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
<?php
//check if you are login
session_start();
if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
header ("Location: login.php");
}
//get user id
$userid= $_SESSION['userName'];
?>
<?php
//connect to database
$connection=mysqli_connect("localhost","root", "", "clubhub");
$connection2=mysqli_connect("localhost","root", "", "clubhub");
if(mysqli_connect_errno()){
die("Database connection fail: ".mysqli_connect_error(). " (" .mysqli_connect_errno().")");
}
?>
<?php
//create query
$checkAdmin = $connection->prepare("SELECT cname FROM role_in natural join club WHERE pid=? and role='Admin'");
$checkAdmin->bind_param("s", $userid);
$checkAdmin->bind_result($cname);
?>
<?php
$checkAdmin->execute();
if($checkAdmin->fetch()){
$checkAdmin->free_result();
?>
<form action="newevent.php" method="post">
Event Name: <input type="text" name="ename" value="" required /><br><br>
Description: <textarea name="descr" rows="5" cols="40"></textarea><br><br>
Date and Time: <input type="datetime-local" name="edatetime" value="" /><br><br>
Location: <input type="text" name="location" value="" /><br><br>
Is it Public:
<input type="radio" name="e_is_public" value="1" checked>Yes
<input type="radio" name="e_is_public" value="0">No <br><br>
Sponsor by: <input type="number" name="cname" value="" required /><br><br>
<input type="submit" name="submit" value="Post Event" />
</form>
<?php
}
else{
echo "Sorry you are not an admin. You can't post new event";
}
?>
<?php
mysqli_close($connection);
mysqli_close($connection2);
?>
<a href="logout.php">logout</a> <br>