<?php
$YourName = $_POST['YourName'];
$Email = $_POST['Email'];
$Phone = $_POST['Phone'];
$Message = $_POST['Message'];
$conn = new mysqli('localhost','root','','jayinfo contact');
if($conn->connect_error){
die('connection failed :'.$conn->connect_error);
}else{
$stmt = $conn->prepare("insert into contact(YourName,Email,Phone,Message) values(?,?,?,?)");
$stmt->bind_param("ssis",$YourName,$Email,$Phone,$Message);
$stmt->execute();
echo"Contact SUccessfully...";
$stmt->close();
$conn->close();
}
?>
What I have tried:
Q. Notice: Undefined variable: servername in C:\xampp\htdocs\Jayinfo\index.php on line 8 Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'jayinfo contact'@'localhost' (using password: NO) in C:\xampp\htdocs\Jayinfo\index.php on line 8 Connection failed: Access denied for user 'jayinfo contact'@'localhost' (using password: NO) this error i got.
I got this error I cant connect html form to databse.
I search on YouTube, Google and friend circle but I couldn't get this problem solution please give me a solution.