Back-End Development PHP and database

PHP deleting data from MySQL database

PHP deleting data from MySQL database -delete command

Learn about SQL delete command. Please refer to the post.

PHP deleting data from MySQL database

Creating a form

  1. Form is enclosed in <form> </form> tags.
  2. Specify the method attribute as GET or POST depending on the data being sent to the php script
  3. Set the action attribute with the URL of the php script eg:request-handler.php
  4. NOTE: Each input/select/textarea field in the form should contain name attribute. Without name attribute the value submitted will not be sent to the script.
  5. A sample form

    Demo database:

    PHP deleting data from MySQL database

    PHP deleting data from MySQL database – request-handler.php

    Here we will use email value entered by the user to match it to the row where the column containing password.

    The delete query

    This query deletes the record information from the database. where emailid='$email' AND password='$password'is used to match the row to the email of the user.This deletes the required row.

    How it is done:

    1. User fills the form with his/her email and the new password.
      PHP deleting data from MySQL database
    2. On clicking the submit button ->request-handler.php script is called.
    3. It runs the delete statement on the database.
    4. Rows are affectedPHP deleting data from MySQL database
    5. Resulting database is:PHP deleting data from MySQL database