D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
delete_speaker.php
back
Copy
<?php include "../config.php"; ?> <!DOCTYPE html> <html> <head> <title>Delete Speaker</title> </head> <body> <h1>Delete Speaker</h1> <?php // Check if the speaker ID is provided in the URL if (isset($_GET['spid'])) { $spid = $_GET['spid']; // Create a connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Check if the user has confirmed the deletion if (isset($_POST['confirm'])) { // Delete the speaker $delete_query = "DELETE FROM speakers WHERE spid = $spid"; if ($conn->query($delete_query) === TRUE) { // Redirect to index.php after deletion header("Location: index.php"); exit; // Ensure no further code is executed } else { echo "Error deleting speaker: " . $conn->error; } } ?> <p>Are you sure you want to delete this speaker?</p> <form method="post" action="delete_speaker.php?spid=<?php echo $spid; ?>"> <input type="submit" name="confirm" value="Yes, Delete"> <a href="speaker_management.php">Cancel</a> </form> <?php $conn->close(); } ?> </body> </html> This modified code will redirect to index.php after successfully deleting the speaker, using the header function. The exit statement is used to ensure no further code is executed after the redirection.