Delete data from MySQL #

delete.php
<?php
    require_once('db.php');

    if(isset($_GET['id'])){
        $id = $_GET['id'];
        $sql = "DELETE FROM `product` WHERE id = $id";

        if($con->query($sql) === TRUE){
            header('Location: http://localhost/crud/show.php');
        }else{
            echo "something went wrong";
        }
        
    }else{
        // redirect to show with error
        die('id not provided');
    }

?>

comments powered by Disqus