-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.php
33 lines (27 loc) · 812 Bytes
/
delete.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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "infolinkdb";
// Create a connection
$conn = new mysqli($servername, $username, $password, $database);
// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$id = $_POST["id"];
// Validate username and password (add your validation logic here)
// SQL query to delete data
$sql = "DELETE FROM studentinfo WHERE id = '$id'";
if ($conn->query($sql) === TRUE) {
header("Location: success.html?regNumber=" . urlencode($regNumber));
exit();
} else {
header("Location: error.html?regNumber=" . urlencode($regNumber));
exit();
}
}
// Close the connection
$conn->close();
?>