File "delete_smart.php"

Full path: /home/julaysp1/public_html/pages/delete_smart.php
File size: 1.19 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor &nnbsp; Back

<?php
session_start();
if(!isset($_SESSION['user_id'])){
header("location: ../index.php");
exit;
}
include('../includes/configuration.php');
if (isset($_GET['id']) && isset($_SESSION['user_id'])) {
    // Decode the base64-encoded ID
    $id = base64_decode($_GET['id']);
    $email = base64_decode($_SESSION['user_id']);
    
    // Sanitize the ID to prevent SQL injection
    $id = mysqli_real_escape_string($conn, $id);
    $email = mysqli_real_escape_string($conn, $email);
  
    // Write the SQL query to delete the record with the provided ID
    $sql = "DELETE FROM smartCard WHERE id = '$id' AND email = '$email'";
    
    // Execute the query
    if (mysqli_query($conn, $sql)) {
        // Success message
        header("location: ../smart_list.php?msg=success&text=ডাটা ডিলে হয়েছে সফলভবে। ");
    } else {
        // Error message
        header("location: ../smart_list.php?msg=error&text=এই ফাইলটি আপনি ডিলিট করতে পারবেন না");
    }
} else {
    // If 'id' is not provided in the URL, redirect to the list page
   header("location: ../index.php");
}

// Close the database connection
mysqli_close($conn);
?>