-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuserchallenge-assign.php
80 lines (52 loc) · 1.37 KB
/
userchallenge-assign.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
<?php
//ob_start();
session_start();
// If User is logged => redirect to tavern.php and announce it
if ( !isset($_SESSION['user']) ) {
$_SESSION['logged'] = 1;
header("Location: tavern.php");
echo "<meta http-equiv='refresh' content='0; url=tavern.php'>";
exit;
}
require_once 'inc.php';
// ------------------------------
// Start of Page with some functions
html_head("Challenge User Assign");
navbar('bgimg_challenges');
pageFade();
$id = $_POST['challenge'];
if(($id != "") || ($id != 0)) {
$date_now = date("Y-m-d H:i:s");
$conn = connect_db();
$sql = "INSERT INTO userchallenges (id_challenge, id_user, date_started) VALUES (". $id .", ". $_SESSION['user'] .", '". $date_now ."')";
$res = mysqli_query($conn, $sql);
if ($res) {
echo '
<script>
swal({
title: "Successfully assigned!!",
text: "Challenge has been assigned to you without any problem!",
type: "success",
showConfirmButton: false,
timer: 1990
});
</script>';
echo "<meta http-equiv='refresh' content='2; url=public-challenges.php'>";
} else mysqli_error($conn);
} else {
echo '
<script>
swal({
title: "No challenge on route!!",
text: "You will be redirected to the Public Challenges!",
type: "warning",
showConfirmButton: false,
timer: 1990
});
</script>';
echo "<meta http-equiv='refresh' content='2; url=public-challenges.php'>";
}
mysqli_close($conn);
?>
</body>
</html>