I'm having some difficulty getting my contact form working on my website. Whenever I try submit, it opens index.php, a blank page, rather than actually executing the script and firing off an email.
Here's the form.
<form method="post" action="index.php">
<div class="field">
<label for="name">Name</label>
<input type="text" name="name" id="name" />
</div>
<div class="field">
<label for="email">Email</label>
<input type="email" name="email" id="email" />
</div>
<div class="field">
<label for="message">Message</label>
<textarea name="message" id="message" rows="4"></textarea>
</div>
<ul class="actions">
<li><input type="submit" type="submit" value="Send Message" /></li>
</ul>
</form>
Here's the index.php file I'm using.
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: Test';
$to = 'brett@edge.yt';
$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>';
}
}
?>
PHP is seemingly properly installed on my server, I can use a PHPInfo()
file no problem.