forked from Namslay26/E-Learning-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse_info.php
36 lines (28 loc) · 1023 Bytes
/
course_info.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
<?php
$exists=false;
$data = json_decode(file_get_contents("php://input"));
include 'dbconnect.php';
$email=$data->email;
$course=$data->name;
$sql1 = "Select * from userInfo where Email='$email'";
$result1 = mysqli_query($conn, $sql1);
$row1=mysqli_fetch_array($result1);
$str=$row1['coursesRegistered'];
if(!str_contains($str,$course)) {
if($exists==false) {
$str.=",$course";
$sql2="update userInfo set coursesRegistered='$str' where email='$email'";
mysqli_query($conn,$sql2);
$status="success";
header( "Content-type: application/json" );
$jsonAnswer = array('status' => $status,'email' => $email,'courses' => $str);
echo json_encode($jsonAnswer);
}
}
else{
$status="fail";
header( "Content-type: application/json" );
$jsonAnswer = array('status' => $status,'email' => $email,'courses' => $str);
echo json_encode($jsonAnswer);
}
?>