CRUD PHP

CRUD PHP

by Arup Ratan Nag -
Number of replies: 0

CRUD is an acronym for Create, Read, Update, and Delete. CRUD operations are basic data manipulation for databases. In this tutorial, we'll create a simple PHP application to perform all these operations on a MySQL database table in one place. Well, let's start by creating the table which we'll use in all of our examples.

<?php

 // Check if the form is submitted 

$personName = $_POST['personName']; 

$address = $_POST['address']; 

$mobile = $_POST['mobile']; 

$email = $_POST['email']; 

$message = $_POST['message']; 

$tdate=new DateTime();

 // form a sql query 

$sql = "INSERT INTO tbquery (name, email, mobile,address, comment, postdate) 

VALUES ('". $personName."',

 '". $email ."', 

'". $mobile ."',

 '". $address ."', 

'". $message ."',

 '". $tdate->format('Y-m-d') ."'

 )"; if (mysqli_query($conn, $sql)) { 

echo "Your query posted successfully";

 } else { 

echo "Error: " . $sql . "" . mysqli_error($conn);

 } mysqli_close($conn);

 ?>