-
Notifications
You must be signed in to change notification settings - Fork 0
/
accept-challenge.php
43 lines (22 loc) · 976 Bytes
/
accept-challenge.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
<?php
session_start();
include "include/config.php";
if($_GET['challenge_id'])
{
$challengeId = $_GET['challenge_id'];
$userId = $_SESSION['user_id'];
$teamDetails = mysqli_fetch_array(mysqli_query($con, "SELECT * FROM teams WHERE team_leader_id= '$userId' "));
if(!$teamDetails) {
echo "<script>alert('Please create team first... !'); window.location='create-team.php' </script>";
// header('location:');
} else {
$teamId = $teamDetails['id'];
$updateQuery = mysqli_query($con, "UPDATE challenges set team_id_accepting='$teamId', team_leader_id_accepting='$userId' WHERE id='$challengeId' " );
if($updateQuery) {
echo "<script>alert('Challenge accepted successfully'); window.location='create-team.php' </script>";
} else {
echo "<script>alert('Something went wrong...!'); window.location='created-challenge.php' </script>";
}
}
}
?>