how to post table values in mysql code example
Example 1: HTML form, add the data into it and submit it to the database by connecting it to MySQL database using PHP.
<?php
$con = mysqli_connect('localhost', 'root', '','db_connect');
$txtName = $_POST['txtName'];
$txtEmail = $_POST['txtEmail'];
$txtPhone = $_POST['txtPhone'];
$txtMessage = $_POST['txtMessage'];
$sql = "INSERT INTO `tbl_contact` (`Id`, `fldName`, `fldEmail`, `fldPhone`, `fldMessage`) VALUES ('0', '$txtName', '$txtEmail', '$txtPhone', '$txtMessage')";
$rs = mysqli_query($con, $sql);
if($rs)
{
echo "Contact Records Inserted";
}
?>
Example 2: insert php code
<?php
$host = "localhost";
$username = "username";
$pass = "";
$db="furniture";
$conn=mysqli_connect($host,$username,$pass,$db);
if(!$conn){
die("Data connection error");
}
?>