HOW TO INSERT DATA IN THE DATABASE USING PHP AND MYSQLI

Hello guys, Today we are learning MYSQLI INSERT QUERY execute in the database using php with mysqli. Then lets start.

1. HTML Source Code(Index.php)

<form action="send.php" method="post">
<input type="text" name="name" palceholder="Enter name">
<input type="submit" name="submit" value="Submit">
</form>

2. PHP Source Code(send.php)

<?php
$conn=mysqli_connect("localhost", "root", "", "testproject");
$name=$_POST["name"];
$query=mysqli_query($conn, "INSERT INTO userdetails(name) VALUES('$name')");
if(query==true){
echo"Successfully Inserted";
}
else{
echo"Inserted Failed";
}
?>