0

I am currently working on a contact form that will allow the users to submit messages that will reroute the message to a contact email (general basic php email handler. I am currently using Brackets live preview to view and edit this and am not sure if this has anything to do with the problem I am having

HTML

<form action="mail_handler.php" method="post">
    <div class="w3-row-padding" style="margin:0 -16px 8px -16px">
      <div class="w3-half">
        <input class="w3-input w3-border" type="text" placeholder="Name" required name="name">
      </div>
      <div class="w3-half">
        <input class="w3-input w3-border" type="email" placeholder="Email" required name="email">
      </div>
    </div>
    <input class="w3-input w3-border" type="text" placeholder="Message" required name="message">
    <button class="w3-button w3-black w3-right w3-section" type="submit">
      <i class="fa fa-paper-plane"></i> SEND MESSAGE
    </button>
  </form>

PHP

<?php 
if(isset($_POST['submit'])){
$to = "email@email.com"; 
$from = $_POST['email']; 
$name = $_POST['name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];

$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
header('Location: email_confirm.html');
exit();
}

?>

Again, I am not sure if this is just a problem with brackets or a code error. I would greatly appreciate some feedback. Thank you!

Edit: This is not a issue with variables, please do not mark as a duplicate for missing variables. This problem has been addressed and is not the solution.

1 Answers1

0

Change this in your HTML

<button class="w3-button w3-black w3-right w3-section" type="submit">

With

<input class="w3-button w3-black w3-right w3-section" type="submit" value="Submit" name="submit">
Muhammad Usman
  • 1,403
  • 13
  • 24