0

CSS y PHP of my contact-form. The page works perfectly but I'm trying to send an email and the button of send doesn't work. In the image you can see that when I try to send an email the button stays white. At the same time the button Clear works perfect! I attach my code

CONTACT.HTML

<form action="mail.php" method="POST" class="contact-form">

    <input type="text" name="name" placeholder="Name" class="required">

    <input type="email" name="email" placeholder="Email address" class="contact-form-email required">

    <input type="text" name="subject" placeholder="Subject" class="contact-form-subject">

    <textarea name="message" placeholder="Message" class="required" rows="7"></textarea>

    <div class="response-message"></div>

    <button class="border-button" type="reset" id="reset" name="reset">Limpiar</button>
    <button class="border-button" type="submit" id="submit" name="submit">Enviar</button>

MAIL.PHP

<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "sa*********@*******.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
  • Sorry, it's unclear what you are asking. What is the clue between your code snippets? What exactly does not work? – Heri Sep 15 '17 at 19:24

2 Answers2

1

mail function doesn't work on local server and also you need to set SMTP configuration in PHP to send mail.

Deepansh Sachdeva
  • 1,168
  • 9
  • 16
0

Are you placing your form inside the form tag?

<form action="mail.php" method="post">
<input type="text" name="name" placeholder="Name" class="required">

<input type="email" name="email" placeholder="Email address" class="contact-form-email required">

<input type="text" name="subject" placeholder="Subject" class="contact-form-subject">

<textarea name="message" placeholder="Message" class="required" rows="7"></textarea>

<div class="response-message"></div>

<button class="border-button" type="reset" id="reset" name="reset">Limpiar</button>
<button class="border-button" type="submit" id="submit" name="submit">Enviar</button>
</form>
Dhiraj
  • 2,687
  • 2
  • 10
  • 34
  • The form tag is present; it's just not showing due to Markdown. I'm editing the question now to show it. – Chris Forrence Sep 15 '17 at 19:45
  • Try changing the form method to get, and see if the button fetches the values in the URL, if it does, your form functions well. If it does not, there's something wrong with your form. – Dhiraj Sep 15 '17 at 20:16
  • I wasn't the original poster; you'll probably need to comment on the original question to notify them. – Chris Forrence Sep 15 '17 at 20:52
  • @zuif there's issue about any HTML structuring here. Bad connection requestion happens for mail when SMTP isn't configured. – Deepansh Sachdeva Sep 16 '17 at 04:44