Insert, View, Edit and Delete Record from Database Using PHP and MySQLi

insert-view-edit-and-delete-record

Demo Download

In this tutorial i will explain how to insert, view, edit and delete record from database using PHP and Mysqli, basically this tutorial is a second part of Simple User Registration & Login Script in PHP and MySQLi, in this first part i explained how to create simple user registration and login using PHP and MySQLi, if you do not know how to create user registration and user login form so kindly first check this tutorial Simple User Registration & Login Script in PHP and MySQLi, after that now come back to this tutorial.

Steps to Creating an Insert, View, Edit and Delete Record from Database Using PHP and MySQLi

Now i am assuming that you have already created user registration and login forms which i created in Simple User Registration & Login Script in PHP and MySQLi now i will create another table to keeping records in it, update dashboard.php file and add four more new pages which are insert.php, view.php, edit.php, and delete.php, follow the following steps:

  1. Create Another Table for Records
  2. Update Dashboard File
  3. Create Insert Page
  4. Create View Page
  5. Create Edit/Update Page
  6. Create Delete Page

1. Create Another Table for Records

Execute the below SQL query:

2. Update Dashboard Page

Update dashboard.php file and paste the following code in it.

3. Create Insert Page

Create a page with name insert.php and paste the below code in it.

insert-new-record

4. Create View Page

Create a page with name view.php and paste the below code in it.

view-record

5. Create Edit/Update Page

Create a page with name edit.php and paste the below code in it.

update-record

6. Create Delete Page

Create a page with name delete.php and paste the below code in it.

If you found this tutorial helpful so share it with your friends, developer groups and leave your comment.

Article By
Javed Ur Rehman is a passionate blogger and web developer, he loves to share web development tutorials and blogging tips. He usually writes about HTML, CSS, JavaScript, Jquery, Ajax, PHP and MySQL.

20 Comments

  1. Strict Standards: date() [function.date]: It is not safe to rely on the system’s timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘UTC’ for ‘8.0/no DST’ instead in C:\AppServ\www\file1\edit.php on line 27
    how to solve this one/

  2. Hello, I have noticed that it is possible to delete a record even though it is not logged in, because you do not call auth.php, so just enter the url and any ID and the record will be deleted by external people. It’s easy to fix but it’s important to warn. Sorry for spelling. Thanks, Alexandre Schmitz

  3. I am very new to PHP and MySQL, just copied your code and run everything works perfectly fine. Please can you post code on how to insert more than two records into the Register database?

    I made attempt to add more columns as Gender, Phone Number, Address, etc to be displayed when view.php was executed but ended up getting error message. Please assist.

  4. thank you very much for helping me out start over again with latest mysqli command. if any inquiry may i know your email?

  5. As Salam Alaikum, do you think it is possible for there to be a page where the user may only be able to modify their own details? e.g. change only their own password.

  6. hi, first off, thank you for the clear code. One problem though, when I try to add a user and click the submit button, it goes to a blank page but does not add the user. I have tried to look for the problem for two days now with no success. kindly help.

Leave a Reply

Your email address will not be published. Required fields are marked *