-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtotal.php
More file actions
55 lines (46 loc) · 1.8 KB
/
total.php
File metadata and controls
55 lines (46 loc) · 1.8 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
// Check if 'Reg' key is set in POST data, if not, redirect to index.html
if (!isset($_POST["Reg"])) {
exit(header("Location:index.html"));
}
// Database connection details
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mark";
// Establish connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Sanitize input data from POST
$r = preg_replace("/[^0-9]/", "", $_POST["Reg"]);
$n = preg_replace("/[^A-z.\s]/", "", $_POST["Name"]);
// Query to get 'Total' from 'Marks' table where 'Regno' and 'Name' match sanitized values
$sql = "SELECT Total FROM Marks where Regno='$r' and Name='$n' ";
// Execute the query
$t = $conn->query($sql);
// Echo HTML head and style tags
echo '<head><title>Total Arrear Count</title><link rel="icon" type="image/png" href="files/favicon.ico"><meta name="viewport" content="width=device-width, initial-scale=1"></head><style>
@font-face {
font-family:Montserrat-Regular;
src: url("Montserrat-Regular.ttf");
}
*{font-family:Montserrat-Regular;}
</style>';
// Check if there is a row in the result set
if ($row = $t->fetch_assoc()) {
// Echo total arrear count with styling and a button to view details
echo '<center style="padding:18%;"><span style="line-height:1px;"><p style="font-size:55px; width:20%;">' .
$row["Total"] .
'</p><p style="font-size:35px;width:25%;">Total</p></span><br><br><form action="marks.php" method="GET"><button name="RegNo" type="submit" value="' .
$r .
'" style="font-size:30px; border-radius:5px;">Details</button></form></center>';
} else {
// Echo "Invalid" if there is no matching record
echo "Invalid";
}
// Close the database connection
$conn->close();
?>