SlideShare a Scribd company logo
4
Most read
7
Most read
8
Most read
3.Create connection.php file
<?php
// Enter your Host, username, password, database below.
// I left password empty because i do not set password on localhost.
$con=mysqli_connect('localhost','root','','myprograming') or die("connection failed :
".mysqli_connect_error());
if ($con) {
// echo "Connection Successfully";
}
else{
echo "Sorry Some Mistakes is";
}
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
4.Create index.php file
<!DOCTYPE html>
<html>
<head>
<title>insert</title>
</head>
<body>
<div class="row text-center">
<div class="container">
<h1>Insert DATA</h1>
<form action="index.php" method="post">
<input type="text" name="firstname" placeholder="firstname"><br><br>
<input type="text" name="lastname" placeholder="lastname"><br><br>
<input type="gmail" name="gmail" placeholder="gmail"><br><br>
<input type="text" name="number" placeholder="number"><br><br>
<input type="text" name="address" placeholder="address"><br><br>
<input type="submit" name="submit" value="insert"><br><br>
</form>
<button><a href="show.php">show data</a></button>
</div>
</div>
</body>
</html>
<?php
error_reporting(0);
include 'connection.php';
if (isset($_POST['submit'])) {
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$gmail = $_POST['gmail'];
$number = $_POST['number'];
$address = $_POST['address'];
$sql = "INSERT INTO `reg` VALUES ('$id','$firstname','$lastname','$gmail','$number','$address')";
$data=mysqli_query($con,$sql);
if ($data) {
echo "insert";
}else
{
echo "sorry";
}
}
?>
5.Create show.php file
<!DOCTYPE html>
<html>
<head>
<title>show table</title>
</head>
<body>
<?php
include ('connection.php');
$sql ="select * from reg";
$data =mysqli_query($con,$sql);
$total=mysqli_num_rows($data);
if ($total=mysqli_num_rows($data)) {
?>
<table border="2">
<tr>
<th>id</th>
<th>firstname</th>
<th>lastname</th>
<th>gmail</th>
<th>number</th>
<th>address</th>
<th>delete</th>
<th>update</th>
</tr>
<?php
while ($result = mysqli_fetch_array($data)) {
echo "
<tr>
<td>".$result['id']."</td>
<td>".$result['firstname']."</td>
<td>".$result['lastname']."</td>
<td>".$result['gmail']."</td>
<td>".$result['number']."</td>
<td>".$result['address']."</td>
<td><a href='update.php?id=$result[id] & firstname=$result[firstname]
& lastname=$result[lastname] & gmail=$result[gmail] & number=$result[number]
&address=$result[address]'> update </a></td>
<td><a href='delete.php?id=$result[id] '>delete </a></td>
</tr>
";
}
}
else
{
echo "no record found";
}
?>
</table>
</body>
</html>
<!--------- echo "<br>".$result['id']." ".$result['firstname']." ".$result['lastname']." ".$result['gmail']."
".$result['number']." ".$result['address']."<br>";_----->
6.Create update.php file
<!DOCTYPE html>
<html>
<head>
<title>update</title>
</head>
<body>
<form action="" method="get">
<input type="text" name="id" placeholder="id" value="<?php echo $_GET['id']; ?>"><br><br>
<input type="text" name="firstname" placeholder="firstname" value="<?php echo
$_GET['firstname']; ?>"><br><br>
<input type="text" name="lastname" placeholder="lastname" value="<?php echo
$_GET['lastname']; ?>" ><br><br>
<input type="gmail" name="gmail" placeholder="gmail" value="<?php echo $_GET['gmail'];
?>"><br><br>
<input type="text" name="number" placeholder="number" value="<?php echo
$_GET['number']; ?>"><br><br>
<input type="text" name="address" placeholder="address" value="<?php echo
$_GET['address']; ?>"><br><br>
<input type="submit" name="submit" value="update">
</form>
<?php
error_reporting(0);
include ('connection.php');
if ($_GET['submit'])
{
$id = $_GET['id'];
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
$gmail = $_GET['gmail'];
$number = $_GET['number'];
$address = $_GET['address'];
$sql="UPDATE reg SET firstname='$firstname' , lastname='$lastname', gmail='$gmail' ,
number='$number', address='$address' WHERE id='$id'";
$data=mysqli_query($con, $sql);
if ($data) {
//echo "record update";
header('location:show.php');
}
else{
echo "not update";
}
}
else
{
echo "click on button to save the change";
}
?>
</body>
</html>
7.Create delete.php file
<?php
include ('connection.php');
$id = $_GET['id'];
$sql ="DELETE FROM `reg` WHERE id='$id'";
$data = mysqli_query($con,$sql);
if ($data) {
echo "deleted";
header('location:show.php');
}else
{
echo "error";
}
?>

More Related Content

PDF
Design patterns in PHP
PPTX
Getting Started with MySQL I
PPTX
SQL commands
PDF
CSS selectors
PPTX
PowerShell-1
DOC
Database queries
PPTX
Python OOPs
PPTX
Database Connectivity in PHP
Design patterns in PHP
Getting Started with MySQL I
SQL commands
CSS selectors
PowerShell-1
Database queries
Python OOPs
Database Connectivity in PHP

What's hot (20)

ODP
Method Handles in Java
PPTX
Job Automation using Linux
PDF
Introduction to html
PDF
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PPT
DB2 LUW Auditing
PDF
File permission of linux
PDF
How to Design Indexes, Really
PPT
Bash shell
PPT
2 db2 instance creation
PDF
Python - object oriented
PPTX
Quill vs Slick Smackdown
PPSX
ADO.NET
PPT
SQL select statement and functions
PDF
File operations
ODP
Ms sql-server
PPTX
Introduction to Powershell Version 5
PDF
Functions in python
PDF
Recursive Query Throwdown
PPTX
MySQL Indexing - Best practices for MySQL 5.6
PDF
Python/Django Training
Method Handles in Java
Job Automation using Linux
Introduction to html
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
DB2 LUW Auditing
File permission of linux
How to Design Indexes, Really
Bash shell
2 db2 instance creation
Python - object oriented
Quill vs Slick Smackdown
ADO.NET
SQL select statement and functions
File operations
Ms sql-server
Introduction to Powershell Version 5
Functions in python
Recursive Query Throwdown
MySQL Indexing - Best practices for MySQL 5.6
Python/Django Training
Ad

Similar to CRUD OPERATIONS using MySQL connectivity in php (20)

DOC
Creating a Simple PHP and MySQL-Based Login System
PPTX
PHP DATABASE MANAGEMENT.pptx
PPTX
This slide show will brief about database handling
PPTX
User registration and login using stored procedure in php
PPTX
Connecting_to_Database(MySQL)_in_PHP.pptx
PDF
HOW TO UPLOAD AND DISPLAY IMAGE PHP HTML SQL
PPTX
My_sql_with_php
DOCX
Php mysql connectivity
PPSX
Php session
PPTX
CHAPTER six DataBase Driven Websites.pptx
PDF
The HyperText Markup Language or HTML is the standard markup language
PDF
Login and Registration form using oop in php
PPTX
7. PHP and gaghhgashgfsgajhfkhshfasMySQL.pptx
PDF
Diving into php
ODP
My app is secure... I think
PDF
How to Create Login and Registration API in PHP.pdf
PPTX
chapter_Seven Database manipulation using php.pptx
PPTX
18.register login
DOC
Tutorial asp.net
PPTX
Php talk
Creating a Simple PHP and MySQL-Based Login System
PHP DATABASE MANAGEMENT.pptx
This slide show will brief about database handling
User registration and login using stored procedure in php
Connecting_to_Database(MySQL)_in_PHP.pptx
HOW TO UPLOAD AND DISPLAY IMAGE PHP HTML SQL
My_sql_with_php
Php mysql connectivity
Php session
CHAPTER six DataBase Driven Websites.pptx
The HyperText Markup Language or HTML is the standard markup language
Login and Registration form using oop in php
7. PHP and gaghhgashgfsgajhfkhshfasMySQL.pptx
Diving into php
My app is secure... I think
How to Create Login and Registration API in PHP.pdf
chapter_Seven Database manipulation using php.pptx
18.register login
Tutorial asp.net
Php talk
Ad

More from KavithaK23 (10)

DOCX
PHP record- with all programs and output
DOCX
PHP Lab template for lecturer log book- and syllabus
PDF
unit 3.pdf
DOCX
Unit III.docx
DOCX
Unit 4 - 2.docx
PDF
unit 4 - 1.pdf
PDF
unit 5 -2.pdf
PDF
unit 5 -1.pdf
DOCX
UNIT 5.docx
PDF
unit 2 -program security.pdf
PHP record- with all programs and output
PHP Lab template for lecturer log book- and syllabus
unit 3.pdf
Unit III.docx
Unit 4 - 2.docx
unit 4 - 1.pdf
unit 5 -2.pdf
unit 5 -1.pdf
UNIT 5.docx
unit 2 -program security.pdf

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Cloud computing and distributed systems.
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Machine learning based COVID-19 study performance prediction
PDF
Electronic commerce courselecture one. Pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
MYSQL Presentation for SQL database connectivity
Programs and apps: productivity, graphics, security and other tools
NewMind AI Weekly Chronicles - August'25 Week I
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Review of recent advances in non-invasive hemoglobin estimation
MIND Revenue Release Quarter 2 2025 Press Release
Cloud computing and distributed systems.
Understanding_Digital_Forensics_Presentation.pptx
Spectroscopy.pptx food analysis technology
Machine learning based COVID-19 study performance prediction
Electronic commerce courselecture one. Pdf
Spectral efficient network and resource selection model in 5G networks
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Approach and Philosophy of On baking technology

CRUD OPERATIONS using MySQL connectivity in php

  • 1. 3.Create connection.php file <?php // Enter your Host, username, password, database below. // I left password empty because i do not set password on localhost. $con=mysqli_connect('localhost','root','','myprograming') or die("connection failed : ".mysqli_connect_error()); if ($con) { // echo "Connection Successfully"; } else{ echo "Sorry Some Mistakes is"; } // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } ?> 4.Create index.php file <!DOCTYPE html> <html> <head> <title>insert</title>
  • 2. </head> <body> <div class="row text-center"> <div class="container"> <h1>Insert DATA</h1> <form action="index.php" method="post"> <input type="text" name="firstname" placeholder="firstname"><br><br> <input type="text" name="lastname" placeholder="lastname"><br><br> <input type="gmail" name="gmail" placeholder="gmail"><br><br> <input type="text" name="number" placeholder="number"><br><br> <input type="text" name="address" placeholder="address"><br><br> <input type="submit" name="submit" value="insert"><br><br> </form> <button><a href="show.php">show data</a></button> </div> </div> </body> </html> <?php error_reporting(0); include 'connection.php'; if (isset($_POST['submit'])) { $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $gmail = $_POST['gmail'];
  • 3. $number = $_POST['number']; $address = $_POST['address']; $sql = "INSERT INTO `reg` VALUES ('$id','$firstname','$lastname','$gmail','$number','$address')"; $data=mysqli_query($con,$sql); if ($data) { echo "insert"; }else { echo "sorry"; } } ?> 5.Create show.php file <!DOCTYPE html> <html> <head> <title>show table</title> </head> <body> <?php include ('connection.php'); $sql ="select * from reg"; $data =mysqli_query($con,$sql); $total=mysqli_num_rows($data);
  • 4. if ($total=mysqli_num_rows($data)) { ?> <table border="2"> <tr> <th>id</th> <th>firstname</th> <th>lastname</th> <th>gmail</th> <th>number</th> <th>address</th> <th>delete</th> <th>update</th> </tr> <?php while ($result = mysqli_fetch_array($data)) { echo " <tr> <td>".$result['id']."</td> <td>".$result['firstname']."</td> <td>".$result['lastname']."</td> <td>".$result['gmail']."</td> <td>".$result['number']."</td> <td>".$result['address']."</td> <td><a href='update.php?id=$result[id] & firstname=$result[firstname] & lastname=$result[lastname] & gmail=$result[gmail] & number=$result[number] &address=$result[address]'> update </a></td>
  • 5. <td><a href='delete.php?id=$result[id] '>delete </a></td> </tr> "; } } else { echo "no record found"; } ?> </table> </body> </html> <!--------- echo "<br>".$result['id']." ".$result['firstname']." ".$result['lastname']." ".$result['gmail']." ".$result['number']." ".$result['address']."<br>";_-----> 6.Create update.php file <!DOCTYPE html> <html> <head> <title>update</title> </head>
  • 6. <body> <form action="" method="get"> <input type="text" name="id" placeholder="id" value="<?php echo $_GET['id']; ?>"><br><br> <input type="text" name="firstname" placeholder="firstname" value="<?php echo $_GET['firstname']; ?>"><br><br> <input type="text" name="lastname" placeholder="lastname" value="<?php echo $_GET['lastname']; ?>" ><br><br> <input type="gmail" name="gmail" placeholder="gmail" value="<?php echo $_GET['gmail']; ?>"><br><br> <input type="text" name="number" placeholder="number" value="<?php echo $_GET['number']; ?>"><br><br> <input type="text" name="address" placeholder="address" value="<?php echo $_GET['address']; ?>"><br><br> <input type="submit" name="submit" value="update"> </form> <?php error_reporting(0); include ('connection.php'); if ($_GET['submit']) { $id = $_GET['id']; $firstname = $_GET['firstname']; $lastname = $_GET['lastname']; $gmail = $_GET['gmail']; $number = $_GET['number']; $address = $_GET['address']; $sql="UPDATE reg SET firstname='$firstname' , lastname='$lastname', gmail='$gmail' , number='$number', address='$address' WHERE id='$id'";
  • 7. $data=mysqli_query($con, $sql); if ($data) { //echo "record update"; header('location:show.php'); } else{ echo "not update"; } } else { echo "click on button to save the change"; } ?> </body> </html> 7.Create delete.php file <?php include ('connection.php'); $id = $_GET['id']; $sql ="DELETE FROM `reg` WHERE id='$id'"; $data = mysqli_query($con,$sql); if ($data) { echo "deleted"; header('location:show.php');