Back-End Development PHP and database

PHP updating data in MySQL database

PHP updating data in MySQL database -update command

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

PHP updating data in 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 updating data in MySQL database

    PHP updating data in 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 update query

    This query updates the new information to the database. where emailid='$email'is used to match the row to the email of the user.This updates the required row.

    How it is done:

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