Im trying to create a contact form in xampp, but I don't know why the form isn't sending the email. The php form also displays no errors even if it is told to. I have the file in the proper localhost directory, yet it does not perform correctly. Here is the code I use
<?php
if (empty($_POST) === false) {
$errors = array();
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
if (empty($name) === true || empty($email) === true || empty($message) === true) {
$errors[] = 'Name, email and message are required!';
} else {
if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
$errors[] = 'That\'s not a valid email address';
}
if (ctype_alpha($name) === false) {
$error[] = 'Name must only contain letters';
}
}
if (empty($errors) === true) {
mail('admin@localhost', 'Contact form', $message, 'From: ' . $email);
header('Location: www.artfbla.org/contact.php?sent');
exit();
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if (isset($_GET['sent']) === true) {
echo '<p>Thanks for contacting us!</p>';
} else {
if (empty($errors) === false) {
echo '<ul>';
foreach($errors as $error) {
echo '<li>', $error, '</li>';
}
echo '</ul>';
}
?>
<form action="" method"post">
<p>
<label for "name">Name:</label><br />
<input type="text" name"name" id="name" <?php if (isset($_POST['name']) === true) { echo strip_tags($_POST['name']); } ?> >
</p>
<p>
<label for="email">Email:</label><br />
<input type="text" name="email" id="email" <?php if (isset($_POST['email']) === true) { echo strip_tags($_POST['email']); } ?>>
</p>
<p>
<label for "message">Message:</label><br />
<textarea name"message" id="message"><?php if (isset($_POST['message']) === true) { echo strip_tags($_POST['message']); } ?></textarea>
</p>
<p>
<input type="submit" value="Submit" >
</p>
</form>
<?php
}
?>
</body>
</html>