insert data in sql data base using php

<?php
$con = mysqli_connect(‘localhost’ , ‘root’ , ‘*****’ );
if(!$con)
{
echo ‘NOT CONNECTED : ‘;
}
if(!mysqli_select_db($con,’stu’))
{
echo ‘Database Not Selected :’;
}
$name = $_POST[‘name’];
$email = $_POST[’email’];
$sql = “INSERT INTO data (name, email) VALUES (‘$name’,’$email’)”;
if(!mysqli_query($con,$sql))
{
echo ‘NOT Inserted’;
}
else {
echo “<h1> Data Inserted Successfully…:) </h1>”;
}
header(“refresh:5; url=index.php”);
?>
Previous Post
Next Post
Related Posts

0 Comments: