-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateexaminer.php
48 lines (41 loc) · 1.53 KB
/
updateexaminer.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
37
38
39
40
41
42
43
44
45
46
47
48
<?php
session_start();
include "db_conn.php";
if (isset($_POST['fullname']) && isset($_POST['email']) && isset($_POST['username']) && isset($_POST['password'])) {
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$fullname = test_input($_POST['fullname']);
$password = test_input($_POST['password']);
$username = test_input($_POST['username']);
$email = test_input($_POST['email']);
$id = test_input($_POST['id']);
$role = "examiner";
if (empty($fullname)) {
header("Location: ../examiner/createexaminerpage.php?error=fullname is Required");
} else if (empty($password)) {
header("Location: ../examiner/createexaminerpage.php?error=Password is Required");
} else if (empty($username)) {
header("Location: ../examiner/createexaminerpage.php?error=username is Required");
} else if (empty($email)) {
header("Location: ../examiner/createexaminerpage.php?error=email is Required");
} else {
// Hashing the password
$password = md5($password);
$sql = "UPDATE examineruser
SET fullname='$fullname', email='$email', password='$password',username='$username',role='$role'
WHERE id=$id";
$result = mysqli_query($conn, $sql);
if ($result) {
header("Location: ../adminfile/admin.php?success=Successfully Updated");
} else {
header("Location: ../examiner/createexaminerpage.php?error=unknown error occurred&$user_data");
}
}
} else {
header("Location: ../examiner/createexaminerpage.php?error=Please fill in all required fields");
}