I'm trying to delete a row in a mySQL table 'users'. It's supposed to delete a users account when a linked button is clicked it takes them to this delete.php page. However, instead of bringing me back to the login page, it keeps me signed in to the account that's supposed to be deleted. I've tried a few other variations however it either doesn't delete the account or returns an error depending on how I wrote it.
<?php
// Initialize the session
session_start();
require_once "config.php";
//delete the mySQL row
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
$sql = "DELETE FROM users WHERE id = 'id'";
mysqli_query($link, $sql);
header("location: login.php");
exit;
}
?>
The same thing happens when I try this:
<?php
// Initialize the session
session_start();
include "config.php";
$id = $_REQUEST["id"];
//delete the mySQL row
$sql="DELETE FROM users WHERE id='$id'";
mysqli_query($sql);
header("location: login.php");
exit;
?>