I don't have any skills in PHP, but I want to create the contact form in my HTML file and I'm creating this codes with web tutorial:
Html:
<form method="post" action="mail.php">
  <label for="name">name</label>
  <input type="text" id="fname" name="name">
  <label for="email">Email</label>
  <input type="email" id="lname" name="email">
  <label for="subject">message</label>
  <textarea id="subject" name="message" style="height:200px"></textarea>
  <input type="submit" value="submit">
</form>
mail.php :
<?php include 'database.php';?>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: MyWeb'; 
$to = 'MyEmail'; 
$subject = 'Hello';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) { 
    echo '<p>Your message has been sent!</p>';
} else { 
    echo '<p>Something went wrong, go back and try again!</p>'; 
}
}
?>
I create a new database and edit this file: database.php:
<?php
function OpenCon()
{
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$db = "myDatabaseName";
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: 
%s\n". $conn -> error);
return $conn;
}
function CloseCon($conn)
{
$conn -> close();
}
?>
and then upload this files into htaccesss directory. but now the form isn't working. what should I do?
 
     
    