-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprof_controller.php
More file actions
36 lines (29 loc) · 907 Bytes
/
Copy pathprof_controller.php
File metadata and controls
36 lines (29 loc) · 907 Bytes
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
include ('dbconfig.php');
session_start();
// login
if (isset ($_POST['login_btn'])) {
$cin = $_POST['cin'];
$password = $_POST['password'];
$query = "SELECT * FROM professeurs WHERE CIN = '$cin' AND Password = '$password'";
$query_run = mysqli_query($connection, $query);
if (mysqli_num_rows($query_run) > 0) {
// valid
$row = mysqli_fetch_assoc($query_run);
$_SESSION['ProfesseurID'] = $row['ProfesseurID'];
$_SESSION['Professeur_name'] = $row['Professeur_name'];
header('location: prof_espace.php');
} else {
// invalid
$_SESSION['status'] = "CIN ou mot de passe incorrect";
header('location: prof_log.php');
}
}
// logout
if (isset ($_POST['logout_btn'])) {
session_destroy();
unset($_SESSION['ProfesseurID']);
unset($_SESSION['Professeur_name']);
header('location: log.php');
}
?>