In this tutorial, we will learn how to create CRDU operation with image using PHP and MySQLi.
Files includes in this tutorials
- phpcrud.sql: Contain the database table structure.
- dbconnection.php: Used for database connection.
- index.php: Used to fetch the record from the database.
- insert.php: Used to insert the new record.
- read.php: Used to fetch the record of the particular user.
- edit.php: Used to edit the record.
- change-image.php: Used to change the profile pic.
Step 1– Create a database
Open browser type //localhost/phpmyadmin
, create a database named ‘phpcrud’. After creating the database run the SQL script or import the SQL file.
MySQL Table tblusers structure
CREATE TABLE`tblusers`[ `ID`int[10]NOTNULL, `FirstName` varchar[200]DEFAULTNULL, `LastName`varchar[200]DEFAULTNULL, `MobileNumber` bigint[10]DEFAULTNULL, `Email`varchar[200]DEFAULTNULL, `Address`mediumtext DEFAULTNULL, `ProfilePic`varchar[200]DEFAULTNULL, `CreationDate`timestamp NOTNULL DEFAULTcurrent_timestamp[]ON UPDATE current_timestamp[] ]ENGINE=InnoDB DEFAULTCHARSET=utf8mb4; |
Step 2– Create a database connection file[dbconnection.php]
|
Step 3– Create an HTML form for data insertion. [insert.php]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | Fill Data Fill below form.
Only jpg/jpeg/ png/gif format allowed.
Submit
|
Step 4– Now write PHP Code for data insertion and put this code at the top of the insert.php file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
Chủ Đề |