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”>
    <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>
    <font style=”font-size: 20px;”>Enter details for DELETE record</font>
    <form action=”form.php” method=”post”>
        <font style=”font-size: 20px;”>Enter email</font>
        <input type=”email” name=”email” required>
        <font style=”font-size: 20px;”>Phone</font>
        <input type=”text” name=”phone” required>
        <input type=”submit” value=”submit”>

File – form.php

// 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>”;
    $phone = $_POST[‘phone’];
    $email = $_POST[’email’];
    $phone = mysqli_real_escape_string($conn,$phone);
     $email = mysqli_real_escape_string($conn,$email);
    // executing prepared statement.
} else {
    echo “query not executed!”;

File – phpmyadmin before

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

File – phpmyadmin after