Skip to content

Instantly share code, notes, and snippets.

@srph
Last active August 29, 2015 14:13
Show Gist options
  • Save srph/a2ac2edf4682f55b78bc to your computer and use it in GitHub Desktop.
Save srph/a2ac2edf4682f55b78bc to your computer and use it in GitHub Desktop.
<?php
require 'database.php';
if ( !isset($_GET['id']) ) {
echo 'Please specify the id of the user to be deleted!';
die();
}
$query = 'DELETE FROM `user` WHERE id = :id';
$statement = $pdo->prepare($query);
//bind the id of the record to be deleted
//use "i" letter for integer
$statement->bind_param(":id", $_GET['id']);
//execute delete statement
$statement->excute();
//close the prepared statement
$statement->close();
//redirect to index page
//parameter used to tell once data been deleted
header('Location:index.php? action=delete');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment