-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeleteinfo2.php
More file actions
30 lines (23 loc) · 754 Bytes
/
deleteinfo2.php
File metadata and controls
30 lines (23 loc) · 754 Bytes
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
<?php
// Establish a connection to the MySQL server
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "student";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Handle record deletion
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['delete'])) {
$idToDelete = $_POST['delete'];
// Delete the selected record from the "student_info" table
$deleteSql = "DELETE FROM student_info WHERE id = $idToDelete";
if ($conn->query($deleteSql) === TRUE) {
echo "Record deleted successfully!";
} else {
echo "Error deleting record: " . $conn->error;
}
}
?>