Here we will, delete record of existing table using delete prepared statement.

  • Delete person whole record on the basics of their email address & phone using prepared statement.

File – form.html

<!DOCTYPE html>
<html lang=”en”>
<head>
    <meta charset=”UTF-8″>
    <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
    <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
    <title>delete form</title>
</head>
<body>
    <br>
    <font style=”font-size: 20px;”>Enter details for DELETE record</font>
    <br>
    <br>
  
    <form action=”form.php” method=”post”>
        <font style=”font-size: 20px;”>Enter email</font>
        <br>
        <input type=”email” name=”email” required>
        <br><br>
        <font style=”font-size: 20px;”>Phone</font>
        <br>
        <input type=”text” name=”phone” required>
        <br><br>
        <input type=”submit” value=”submit”>
    </form>
</body>
</html>
output

File – form.php

<?php
error_reporting(0);
// creating connection with mysql-database.
$conn = mysqli_connect(‘localhost’,’root’,”,’prepared’);
 
// ? = annonimos placeholder.
$sql=”DELETE FROM customers WHERE phone=? && email=?”;
$query = mysqli_prepare($conn,$sql);
 
// if query failed then it will stoped here!
if ($query) {
    echo “<br><br><font color=’red’> your query executed! record deleted!!</font>”;
    mysqli_stmt_bind_param($query,’is’,$phone,$email);
   
 
    $phone = $_POST[‘phone’];
    $email = $_POST[’email’];
 
    $phone = mysqli_real_escape_string($conn,$phone);
     $email = mysqli_real_escape_string($conn,$email);
 
    // executing prepared statement.
    mysqli_stmt_execute($query);
 
} else {
    echo “query not executed!”;
}
?>
output

File – phpmyadmin before

Note: we have delete person’s whole record on the basics of their phone & email address.

File – phpmyadmin after