I have a website and want people to be able to send me an email through a form. I have followed this tutorial here, but it doesn't send the email.
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: FPSUsename.xyz';
$to = 'FPSUsername@outlook.com';
$subject = $_POST['subject'];
$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>';
}
}
?>
<form method="post" action="index.php">
<div class="field">
<label for="name">Name</label>
<input type="text" name="name" placeholder="Your Name">
</div>
<div class="field">
<label for="email">Email</label>
<input type="email" name="email" placeholder="Your Email">
</div>
<div class="field">
<label for="subject">Subject</label>
<input type="text" name="subject" placeholder="Subject"/>
</div>
<div class="field">
<label for="message">Message</label>
<textarea name="message" id="message" rows="4" placeholder="Message"></textarea>
</div>
<ul class="actions">
<li><input type="submit" id="submit" name="submit" value="Submit" /></li>
</ul>
</form>
This is the code, yet it always shows "Your message has been sent!" even when I haven't filled in anything. Could somebody help me?