I'm having some difficulty getting my contact form working on my website. It opens a blank page and actually doesn't work at all. I'm not a professional with php. My code is below:
<form action="mail.php" method="post" class="comment-form">
<input name="name" type="text" placeholder="Your Name" required>
<input name="email" type="email" placeholder="Email">
<input type="url" placeholder="Website">
<textarea rows="4" placeholder="Messages"></textarea>
<input type="submit" value="send message">
</form>
And php code:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: Website';
$to = 'myemail@gmail.com';
$subject = 'Email Inquiry';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";?>
<?php
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Thank you for your message!
</p>';
} else {
echo '<p>An error occurred. Try sending your message again.</p>'; }}?>
Aucun commentaire:
Enregistrer un commentaire