localhost
// username => root
// password => empty
// database name => local_demo_db
$conn = mysqli_connect("localhost", "root", "", "local_demo_db");
// Check connection
if($conn === false){
die("ERROR: Could not connect. "
. mysqli_connect_error());
}
// Taking all 5 values from the form data(input)
$first_name = $_REQUEST['first_name'];
$last_name = $_REQUEST['last_name'];
$car_type = $_REQUEST['car_type'];
$capacity = $_REQUEST['capacity'];
$phone_number = $_REQUEST['phone_number'];
// Performing insert query execution
// here our table name is login
$sql = "INSERT INTO login VALUES ('$first_name',
'$last_name','$car_type','$capacity','$phone_number')";
if(mysqli_query($conn, $sql)){
echo "data stored in a database successfully."
. " Please browse your localhost php my admin"
. " to view the updated data
";
echo nl2br("\n$first_name\n $last_name\n "
. "$car_type\n $capacity\n $phone_number");
} else{
echo "ERROR: Hush! Sorry $sql. "
. mysqli_error($conn);
}
// Close connection
mysqli_close($conn);
?>