-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.php
More file actions
71 lines (63 loc) · 2.17 KB
/
Copy pathcode.php
File metadata and controls
71 lines (63 loc) · 2.17 KB
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
<?php
session_start();
require('dbconnexion.php');
if(isset($_POST['delete_student'])){
$delete=$_GET['id'];
$query =$pdo->prepare("DELETE FROM add_student WHERE id=?");
$query->execute(array(
$delete
));
if($query){
$_SESSION['message']='student deleted successfully';
header('Location:home.php');
exit(0);
}
else{
$_SESSION['message']='student not deleted';
header('Location:home.php');
exit(0);
}
}
if(isset($_POST['submit_update'])){
$student_id=$_GET['id'];
$name =htmlspecialchars($_POST['name']);
$email =htmlspecialchars($_POST['email']);
$phone =htmlspecialchars($_POST['phone']);
$matricule =htmlspecialchars($_POST['matricule']);
$query=$pdo->prepare("UPDATE add_student SET name_student=?,email=?,phone=?,matricule=? WHERE id=?");
$query->execute(array($name,$email,$phone,$matricule,$student_id));
if($query){
$_SESSION['message']='student updated successfully';
header('Location:home.php');
exit(0);
}
else{
$_SESSION['message']='student not updated';
header('Location:home.php');
exit(0);
}
}
if(isset($_POST['submit_create'])){
$name =htmlspecialchars($_POST['name']);
$email =htmlspecialchars($_POST['email']);
$phone =htmlspecialchars($_POST['phone']);
$matricule =htmlspecialchars($_POST['matricule']);
$query = $pdo->prepare("INSERT INTO add_student(name_student,email,phone,matricule) VALUES(:name_student,:email,:phone,:matricule)");
$query->execute(array(
'name_student' => $name,
'email' => $email,
'phone' => $phone,
'matricule' => $matricule
));
if($query){
$_SESSION['message']='student saved successfully';
header('Location:home.php');
exit(0);
}
else{
$_SESSION['message']='student not saved';
header('Location:home.php');
exit(0);
}
}
?>