0

I have been trying to make my first contact form and after hours of googling I can't seem to find the error in my code why it's not working.

My php code:

<?php
$to = 'llavert@gmail.com'; 
$from = strip_tags($_POST['email']); 
$name = strip_tags($_POST['name']);
$adress = strip_tags($_POST['address']);
$city = strip_tags($_POST['city']);
$subject = strip_tags($_POST["subject"]);
$message = strip_tags($_POST['message']);
$header = "From: noreply@example.com\r\n"; 
$header.= "MIME-Version: 1.0\r\n"; 
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
$header.= "X-Priority: 1\r\n"; 
mail($to, $subject, $message, $header);
print_r(error_get_last());

?>

My html form:

<form method="post" action="mailer.php">
                        <input type="text" class="col-md-13 col-xs-12 name" name='name' placeholder='Naam *'/>
                        <input type="text" class="col-md-13 col-xs-12 Email" name='email' placeholder='Email *'/>
                        <input type="text" class="col-md-13 col-xs-12 name" name='address' placeholder='Straat en huisnummer *'/>
                        <input type="text" class="col-md-13 col-xs-12 Email" name='city' placeholder='Postcode en gemeente *'/>
                        <input type="text" class="col-md-12 col-xs-12 Subject" name='subject' placeholder='Onderwerp *'/>
                        <textarea type="text" class="col-md-12 col-xs-12 Message" name='message' placeholder='Bericht aan BDS bvba *'></textarea>
                        <div class="cBtn col-xs-12">
                            <ul>
                                <li class="clear"><a href="#"><i class="fa fa-times"></i>Formulier legen</a></li>
                                <li class="send" name="submit" type="submit" value="Send"><i class="fa fa-share"></i>Bericht sturen</a></li>
                            </ul>
                            <br><br><br><br><br><br><br><br><br>

                        </div>
                    </form>
Pruxis
  • 1
  • 2
  • PS yes I know myemail@mailadress.com has to be my actual email. – Pruxis Aug 30 '15 at 19:04
  • You are checking for `$_POST['adress']` but the form element is `address` – Professor Abronsius Aug 30 '15 at 19:06
  • Try print_r(error_get_last()) if mail returns false. Might give you an idea on where you went wrong. – fdfdfd Aug 30 '15 at 19:07
  • Let me 'address' that error and see if it works :p – Pruxis Aug 30 '15 at 19:07
  • If I go to the mailer.php on my domain it says the succession sentence 'Email verzonden' meaning email has been sent. But when I fill in the form nothing happends when I press the button. Also no errors seem to pop up – Pruxis Aug 30 '15 at 19:10
  • @suppko after adding a header I get this, php file in main post editted so you can see it Error: Array ( [type] => 8 [message] => Undefined index: message [file] => /home/a8234820/public_html/mailer.php [line] => 8 ) – Pruxis Aug 30 '15 at 19:29
  • try replacing your `` to ` ` – fdfdfd Aug 30 '15 at 20:17

1 Answers1

0

From the manual

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

It is most likely that your local mail server is not set up correctly.