-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapprove.php
63 lines (59 loc) · 1.6 KB
/
approve.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
<?php
session_start();
if(!isset($_SESSION['email'])) {
session_destroy();
header("location:index.php");
}
elseif ($_SESSION['email']!="admin") {
session_destroy();
header("location:index.php");
}
?>
<!doctype html>
<html>
<head>
<title>Approve</title>
<meta http-equiv="refresh" content="2; url=dashboard.php">
<link href="./assets/css/custom.css" rel="stylesheet">
</head>
<body style="text-align:center;">
<?php
function dataReceive() {
$email = $_GET["email"];
return $email;
}
function databaseConnection() {
$server = "localhost";
$username = "root";
$password = "";
$dbname = "test";
$conn = mysqli_connect($server, $username, $password, $dbname);
if (!$conn) {
echo "<div class=\"action_failure\">";
echo "Connection failed: " . mysqli_error();
echo "</div>";
return null;
}
return $conn;
}
function dataCheck($conn, $email) {
$sql = "update stu set status = '1' where email = $email";
$res = mysqli_query($conn, $sql);
if (!$res) {
echo "<div class=\"action_failure\">";
echo "Error: ". $sql . "<br>" . mysqli_error($conn);
echo "</div>";
return;
}
else {
echo "<div class=\"action_success\">";
echo "Approved!<br>";
echo "</div>";
}
}
$email = dataReceive();
$conn = databaseConnection();
dataCheck($conn, $email);
?>
</body>
</html>