-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
73 lines (64 loc) · 2.25 KB
/
update.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
# Start the Session
session_start();
include "connection.php";
# Check if the person logged in is the user or admin
# If logged in is user, then redirect to user.php to avoid unwanted connection
if (isset($_SESSION['loggedInAsUser']) && $_SESSION['loggedInAsUser']) {
header("Location:user.php");
}
# If nothing is logged in, redirect to login.php to prompt for login
if (!$_SESSION['loggedInAsAdmin']) {
header("Location:login.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OA Portal | Update</title>
<link rel="stylesheet" href="styles.css" />
<link rel="shortcut icon" type="image/x-icon" href="images/ouran-logo.png" />
</head>
<body>
<div class="header">
<div class="header-school">
<p class="header-title"><b>OURAN</b></p>
<a href="#"><img class="header-logo" src="images/ouran-logo.png" /></a>
<p class="header-title"><b>ACADEMY</b></p>
</div>
<div class="header-menu">
<a href="admin.php" class="menu">MAIN MENU</a>
<a href="logout.php" class="logout">LOGOUT</a>
</div>
</div>
<div class="search-section">
<h2>UPDATE EXISTING DATA</h2>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="GET">
<input type="text" name="studID" placeholder="Enter Student ID" />
<br />
<br />
<input type="submit" value="SEARCH" />
</form>
<?php
# The form returns its data to itself it performs after getting studID
if (isset($_GET['studID'])) {
$studID = $_GET['studID'];
# MySQL query to confirm if there is a matching stud_id to the stud_id being queued
$sql = "SELECT stud_id FROM " . $tableName . " WHERE stud_id = '" . $studID . "';";
$query = mysqli_query($conn, $sql);
# Put the stud_id in the array
$row = mysqli_fetch_array($query);
if (is_array($row)) {
# The stud_id will be parsed into the url
header("Location:updateForm.php?studID=" . urlencode(serialize($row)));
} else {
echo "<span>No student found with ID</span>";
}
}
?>
</div>
</body>
</html>