0

I have this php form:

        <form method="post" action="mailer.php" class="contact-form-map"> 
        <div class="row">
            <input type="text" name="name" id="name" placeholder="Your Name" required>
        </div>
        <div class="row">
            <input type="number" name="number" id="number" placeholder="Contact Number" required>
        </div>
        <div class="row">
            <textarea type="text" name="message" id="message" placeholder="Message" rows="6" cols="33" required></textarea>
        </div>
        <div class="row">
            <input type="submit" class="map-button" value="Send">
        </div>
        </form>

and this is my mailer.php

<?php 
if(isset($_POST['submit'])){

    $to = "lala.lal@gmail.com"; // info@computerrepairscroydon.co.uk

    $name = $_POST['name']; 

    $number = $_POST['number'];

    $subject = "Form submission - Contact";

    $message = $name . " " . " wrote the following:" . "\n\n" . $_POST['message'] . "\n\n" . " Contact number: " . $number ;

    $headers = "From:" . $name;

    mail($to,$subject,$message,$headers);

    echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";

    header("Location: index.html?success=1#form");

    }
?>

When I enter information into de form and click send nothing happens, but the email isn't send, i don't get it on my gmail. Why is that?

user3088738
  • 61
  • 1
  • 2
  • 9

2 Answers2

2

You forgot to write name="submit" to the submit input

<input type="submit" class="map-button" value="Send" name="submit">

that's why the code is "jumping" the if isset $_POST["submit"]

Neobugu
  • 333
  • 6
  • 15
0

You need to add name="submit" to your submit button.

<input type="submit" class="map-button" value="Send" name="submit">
deflox
  • 103
  • 2
  • 8