<?php
// Start the session
session_start();
// Include your database connection file
require_once('../_db.php');
// Check if the required parameters are set
if (isset($_GET['id']) && $_GET['status'] == 'delete') {
// Sanitize the input
$userId = intval($_GET['id']);
// Prepare and execute the SQL statement to delete the user
$stmt = $conn->prepare("DELETE FROM user_login WHERE id = ?");
$stmt->bind_param("i", $userId);
if ($stmt->execute()) {
// If the deletion is successful, set a success message in the session
$_SESSION['mgs'] = 'User deleted successfully.';
} else {
// If there is an error, set an error message in the session
$_SESSION['mgs'] = 'Error deleting user. Please try again.';
}
// Close the statement
$stmt->close();
} else {
// If the required parameters are not set, set an error message in the session
$_SESSION['mgs'] = 'Invalid request. Please try again.';
}
// Redirect back to the page with the user list
header("Location: info.php");
exit();
?>