-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax.php
34 lines (28 loc) · 918 Bytes
/
ajax.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
<?php
session_start();
if(isset($_POST['lecture'])&&isset($_SESSION['user'])){
include 'bdd.php';
$req = $pdo->prepare("SELECT Suivi_ID FROM hoppy_suivi WHERE Lecture_ID=:lecture AND User_ID=:id");
$req->execute(array(
':lecture' => $_POST['lecture'],
':id' => $_SESSION['id']
));
if($req->rowCount()==0){//existe pas
$req = $pdo->prepare("INSERT INTO hoppy_suivi (Lecture_ID, User_ID, Course_DateBegin)
VALUES (:lecture, :id, NOW())");
$req->execute(array(
':lecture' => $_POST['lecture'],
':id' => $_SESSION['id']
));
}
}else if(isset($_POST['deleteS'])&&isset($_SESSION['id'])){
include 'bdd.php';
$req = $pdo->prepare("DELETE FROM hoppy_suivi WHERE Lecture_ID=:lecture AND User_ID=:id");
$req->execute(array(
':lecture' => $_POST['deleteS'],
':id' => $_SESSION['id']
));
}else{
header('Location: login.php');
}
?>