-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteStudent.php
40 lines (34 loc) · 1.08 KB
/
deleteStudent.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
<?php
// Check if the email parameter is set in the POST request
if(isset($_POST['Sphone'])) {
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "Kindergarten";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Prepare and bind the SQL statement to delete the row with the provided email
$stmt = $conn->prepare("DELETE FROM student WHERE Sphone = ?");
$stmt->bind_param("s", $Sphone);
// Set the email parameter from the POST request
$Sphone = $_POST['Sphone'];
// Execute the statement
if ($stmt->execute() === TRUE) {
// Deletion successful
echo "Row deleted successfully";
} else {
// Error occurred
echo "Error: " . $stmt->error;
}
// Close statement and connection
$stmt->close();
$conn->close();
} else {
// If email parameter is not set in the POST request
echo "Sphone parameter not provided";
}
?>