-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdatesettings.php
More file actions
36 lines (31 loc) · 1.16 KB
/
Copy pathupdatesettings.php
File metadata and controls
36 lines (31 loc) · 1.16 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
<?php
session_start();
include_once 'config.php';
$matriculeuser = $_POST['matri'];
$emailuser = $_POST['emaile'];
$firstname = $_POST['first_name'];
$lastname = $_POST['last_name'];
if ($_POST['emaile'] != $_SESSION['email']) {
$_SESSION['email_changed'] = true;
}
if ($_SESSION['studentlogged'] == true){
$sql1 = "UPDATE students SET firstname = '$firstname', lastname = '$lastname', email = '$emailuser' WHERE matricule = '$matriculeuser'";
}
elseif($_SESSION['teacherlogged'] == true){
$sql1 = "UPDATE teachers SET firstname = '$firstname', lastname = '$lastname', email = '$emailuser' WHERE matricule = '$matriculeuser'";
}
$sql2 = "UPDATE accounts SET email = '$emailuser' WHERE matricule = '$matriculeuser'";
if(($conn->query($sql1)===TRUE )&&($conn->query($sql2)===TRUE )&&($_SESSION['email_changed'] == true)){
$_SESSION = array();
session_destroy();
header("Location: index.php?logout=1");
exit;
}
else if(($conn->query($sql1)===TRUE )&&($conn->query($sql2)===TRUE )){
header('Location: profile.php');
} else{
echo "Error: " . $sql1 . "<br>" . $conn->error;
echo"<br>";
echo "Error: " . $sql2 . "<br>" . $conn->error;
}
?>