I’m trying to make a contactform.
And somehow it won’t work.
I tried to send a email just with the mail()-function and that works.
So I’m doing something wrong and I don’t know what.
When you click on the submit button, I refer to the mailer.php file.
Both file are in the same folder.
<?php
if(isset($_POST['sendButton']))
{
$to = "contact@domain.com";
$subject = "Contactformulier Portfolio";
$name_field = $_POST['yourName'];
$email_field = $_POST['yourEmail'];
$message = $_POST['yourMessage'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
}
else
{
echo "There has been some error, try again please!";
}
?>
Without seeing all your code, my guess is that the condition for mailing is never met because there is no value set for the submit button. Try making the condition for emailing like this: