When I submit my form it Dies for an unkown reason.
My form code:
<form action="mail.php" method="post">
<input class="invoeren" name="naamUser" type="text" placeholder="Naam" required>
<input class="invoeren" name="nummerUser" type="text" placeholder="Telefoonnummer" required>
<input class="invoeren" name="onderwerpUser" type="text" placeholder="Onderwerp" required>
<textarea class="invoeren" type="text" name="opmerkingUser" placeholder="Opmerking" required></textarea>
<button type="submit" id="contactButton">Verstuur</button>
</form>
My mail.php file:
<?php
ob_start();
$naamUser = $_POST['naamUser'];
$nummerUser = $_POST['nummerUser'];
$onderwerpUser = $_POST['onderwerpUser'];
$opmerkingUser = $_POST['opmerkingUser'];
$formcontent="Aanvraag formulier Domein naam \n
Naam: $naamUser \n
Telefoonnummer: $nummerUser \n
Onderwerp: $onderwerpUser \n
Opmerking: $opmerkingUser \n
";
$recipient = "[email protected]";
$subject = "Terug Bellen";
$mailheader = "From: $naamUser \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
?>
I use 1 mail.php file for several index.html files, is that maybe the reason why it dies?
"Can you answer this question by your comment? @Fred-ii- Because that's the answer, thanks! – Blank"
As per OP's request:
From: expects an email address, not a name.
Read the manual on mail()
and another comment:
Add error reporting to the top of your file(s) right after your opening PHP tag for example
<?php error_reporting(E_ALL); ini_set('display_errors', 1); then the rest of your code, to see if it yields anything and make sure you've access to mail() and that PHP is in fact running properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With