Create The form
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rays Coding :- PHP Crud Operation</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<div class="container mt-5">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header bg-dark">
<h4 class="text-center text-light">Rays Coding : PHP CRUD Operation</h4>
</div>
<div class="card-body">
<form action="../insert/insert.php" method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label for="username" class="form-label">Name</label>
<input type="text" class="form-control" id="username" name="user_name" placeholder="Enter User Name" autocomplete="off">
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label for="useremail" class="form-label">Email</label>
<input type="email" class="form-control" id="useremail" name="user_email" placeholder="Enter Email Address" autocomplete="off">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label for="usercontact" class="form-label">Mobile Number</label>
<input type="text" class="form-control" id="usercontact" name="user_contact" placeholder="Enter Contact Number" autocomplete="off">
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label for="userprofile" class="form-label">Profile</label>
<input type="file" class="form-control" id="userprofile" name="user_profile" autocomplete="off">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label for="userpassword" class="form-label">Create Password</label>
<input type="password" class="form-control" id="userpassword" name="user_password" placeholder="Create Password" autocomplete="off">
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label for="userpassword" class="form-label">Confirm Password</label>
<input type="password" class="form-control" id="userpassword" name="confirm_user_password" placeholder="Re-Enter Password" autocomplete="off">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-6">
<button type="submit" name="submit_btn" class="btn bg-dark text-light submit_button"><b>Submit</b></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Create The Connection
<?php
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'crud_operation';
$conn = mysqli_connect($host, $username, $password);
mysqli_select_db($conn,$database );
?>
Write Insert Query
<?php
require_once('../connection/conn.php');
if(isset($_POST['submit_btn']))
{
$name = $_POST['user_name'];
$email= $_POST['user_email'];
$contact = $_POST['user_contact'];
$profile = $_FILES['user_profile']['name'];
$profile_temp = $_FILES['user_profile']['tmp_name'];
$profile_location = '../profiles/'.$profile;
$password = $_POST['user_password'];
$confirm_password = $_POST['confirm_user_password'];
if($password == $confirm_password)
{
$insert_data = "INSERT INTO `simple_table`(`name`, `email`, `contact`, `profile`, `password`, `confirm_password`) VALUES ('$name','$email','$contact','$profile','$password','$confirm_password')";
move_uploaded_file($profile_temp, $profile_location);
$insert_query = mysqli_query($conn,$insert_data);
if($insert_query)
{
header('location:../index/index.php');
}
else
{
echo "<script>alert('Data Not Insert.'); window.history.back();</script>";
}
}
else
{
echo "<script>alert('Password Are Not Match'); window.history.back();</script>";
}
}
?>