Skip to content

Instantly share code, notes, and snippets.

@msisaifu
Created June 27, 2022 06:16
Show Gist options
  • Save msisaifu/835fc4ca9beefe239df729bba50c86d6 to your computer and use it in GitHub Desktop.
Save msisaifu/835fc4ca9beefe239df729bba50c86d6 to your computer and use it in GitHub Desktop.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "students";
$table_name = 'student_info';
$inserted = false;
$something_wrong = false;
$id = $_GET['id'];
$rows = null;
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "DELETE FROM {$table_name} WHERE id='{$id}'";
if (mysqli_query($conn, $sql)) {
header("Location: index.php");
} else {
header("Location: index.php");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment