-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit-script.php
More file actions
40 lines (40 loc) · 1.07 KB
/
edit-script.php
File metadata and controls
40 lines (40 loc) · 1.07 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
<?php
session_start();
if (isset($_SESSION['admin'])) {
if (isset($_POST['edit_btn'])) {
include 'db.php';
$id = $_GET['id'];
$name = $_POST['name'];
$matric_no = $_POST['matric_no'];
$phone = $_POST['phone'];
$password = md5($matric_no);
$id = $_POST['id'];
$q0 = $db->prepare('select * from student where matric_no = ?');
$q0->bind_param('s', $matric_no);
$q0->execute();
$q0->store_result();
$n = $q0->num_rows;
if ($n > 0) {
$_SESSION['mnae'] = 1;
header("Location:edit-student.php?id=$id");
exit;
}
$q = $db->prepare('update student set name = ?, matric_no = ?, phone = ?, password = ? where matric_no = ?');
$q->bind_param('sssss', $name, $matric_no, $phone, $password, $id);
$q->execute();
$q->close();
$db->close();
$_SESSION['us'] = 1;
header('Location:view-students.php');
exit;
}
else {
header('Location:view-students.php');
exit;
}
}
else {
header('Location:logout.php');
exit;
}
?>