-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction_pro.php
60 lines (57 loc) · 1.68 KB
/
action_pro.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
<?php
session_start();
?>
<!doctype html>
<html>
<head>
<title>Profile</title>
<meta http-equiv="refresh" content="2; url=profile.php">
<link href="./assets/css/custom.css" rel="stylesheet">
</head>
<body style="text-align:center;">
<?php
function dataReceive() {
$name = $_POST["name"];
$roll = $_POST["roll"];
$sess = $_POST["session"];
$degree = $_POST["degree"];
return array($name, $roll, $sess, $degree);
}
function databaseConnection() {
$server = "localhost";
$username = "root";
$password = "";
$dbname = "test";
$conn = mysqli_connect($server, $username, $password, $dbname);
if (!$conn) {
echo "Connection failed: " . mysqli_error();
return null;
}
return $conn;
}
function dataUpdate($conn, $data) {
$email = $_SESSION['email'];
$name = $data[0];
$roll = $data[1];
$sess = $data[2];
$degree = $data[3];
$sql = "update stu set name='$name', roll='$roll', session='$sess', degree='$degree', status='0', delivery=NULL where email='$email'" ;
$res = mysqli_query($conn, $sql);
if ($res) {
echo "<div class=\"action_success\">";
echo "Congratulations! <br>";
echo "Record updated successfully <br>";
echo "</div>";
}
else {
echo "<div class=\"action_failure\">";
echo "Error: ". $sql . "<br>" . mysqli_error($conn);
echo "</div>";
}
}
$data = dataReceive();
$conn = databaseConnection();
dataUpdate($conn, $data);
?>
</body>
</html>