CRUD operation using PHP and MySQLi | PHP Gurukul

 In this tutorial, we will learn how to create CRUD operation using PHP and MySQLi.



CRUD Stands for create, read, update and delete record in the database.

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 database.
  • read.php: Used to fetch the record of particular user.
  • edit.php: Used to edit the record.
  • insert.php: Used to insert the new record.

Step 1– Create a database

Open browser type http://localhost/phpmyadmin, create a database named ‘phpcrud’. After creating database run the SQL script or import the SQL file.

  1. MySQL Table tblusers structure
  2. CREATE TABLE `tblusers` (
  3. `ID` int(10) NOT NULL,
  4. `FirstName` varchar(200) DEFAULT NULL,
  5. `LastName` varchar(200) DEFAULT NULL,
  6. `MobileNumber` bigint(10) DEFAULT NULL,
  7. `Email` varchar(200) DEFAULT NULL,
  8. `Address` mediumtext DEFAULT NULL,
  9. `CreationDate` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
  10. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Click : https://phpgurukul.com/crud-operation-using-php-and-mysqli/

Step 2– Create a database connection file(dbconnection.php)

  1. <?php
  2. $con=mysqli_connect("localhost", "root", "", "phpcrud");
  3. if(mysqli_connect_errno())
  4. {
  5. echo "Connection Fail".mysqli_connect_error();
  6. }
  7. ?>

Step 3– Create a HTML form for data insertion

<form  method="POST">

<h2>Fill Data</h2>

<p class="hint-text">Fill below form.</p>

 <div class="form-group">

 

<div class="row">

<div class="col"><input type="text" class="form-control" name="fname" placeholder="First Name" required="true"></div>

<div class="col"><input type="text" class="form-control" name="lname" placeholder="Last Name" required="true"></div>

</div>             

</div>

 

<div class="form-group">

<input type="text" class="form-control" name="contactno" placeholder="Enter your Mobile Number" required="true" maxlength="10" pattern="[0-9]+">

        </div>

 

<div class="form-group">

<input type="email" class="form-control" name="email" placeholder="Enter your Email id" required="true">

 

</div>

 

<div class="form-group">

<textarea class="form-control" name="address" placeholder="Enter Your Address" required="true"></textarea>

</div>        

 

<div class="form-group">

<button type="submit" class="btn btn-success btn-lg btn-block" name="submit">Submit</button>

</div>

</form>

Blog : https://phpgurukul.com/how-to-send-email-from-localhost-using-php/

 

PHP Gurukul

Welcome to PHPGurukul. We are a web development team striving our best to provide you with an unusual experience with PHP. Some technologies never fade, and PHP is one of them. From the time it has been introduced, the demand for PHP Projects and PHP developers is growing since 1994. We are here to make your PHP journey more exciting and useful.

Website : https://phpgurukul.com

Comments

Popular posts from this blog

Global Food Ordering System Using PHP and MySQL | PHP Gurukul

Pre-School Enrollment System using PHP and MySQL | PHP Gurukul

Doctor Appointment Management System Using PHP and MySQL | PHP Gurukul