I made a php form but i can't figgure out how I make it auto respond to a email that is filled in. I want to send a confurmation to a person who just used the form that we have it but i dont know how to make it.
Here a example of my code. I want to send a custom mail to the $email how do i do that?!
I made some changes but i dont recive emails jet. Maby i did understand you whrong but can you check it for me again please.
<?php
/* Set e-mail recipient */
$myemail = "opgeven@kidsnthingspernis.nl";
/* Check all form inputs using check_input function */
$subject = check_input($_POST['subject']);
$Voornaam = check_input($_POST['Voornaam'], "Vul A.U.B. uw Voornaam in.");
$Achternaam = check_input($_POST['Achternaam'], "Vul A.U.B. uw Achternaam in.");
$VoornaamKind = check_input($_POST['VoornaamKind'], "Vul A.U.B. de Voornaam van uw in.");
$AchternaamKind = check_input($_POST['AchternaamKind'], "Vul A.U.B. de Achternaam van uw in.");
$email = check_input($_POST['email'], "Vul A.U.B. uw Email adres in.");
$Leeftijd = check_input($_POST['Leeftijd'], "Vul A.U.B. de leeftijd van uw kind in.");
$Groep = check_input($_POST['Groep'], "Vul A.U.B. de basisschoolgroep van uw in.");
$Opmerking= ($_POST['Opmerking']);
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail adres klopt niet");
}
/* Let's prepare the message for the e-mail */
$message = "Hallo!
Je contact formulier is ingevuld door:
Ouder/Verzorger
Voornaam: $Voornaam
Achternaam: $Achternaam
Kind:
Voornaam Kind: $VoornaamKind
Achternaam Kind: $AchternaamKind
E-mail: $email
Groep: $Groep
Leeftijd: $Leeftijd
Opmerking:
$Opmerking
Einde bericht.
"
;
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: bedankt.html');
exit();
/* Functions we used */
function check_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if (strlen($data) == 0)
{
return false;
}
else
{
return $data;
}
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
$email = 'email';
$subject = 'subject';
$message = "Hallo!
U/jij bent nu opgegeven voor Kids N Theatre met De Vliegende Speeldoos.
Dit is wat wij aan gegevens hebben gekregen:
Ouder/Verzorger
Voornaam: $Voornaam
Achternaam: $Achternaam
Kind:
Voornaam Kind: $VoornaamKind
Achternaam Kind: $AchternaamKind
E-mail: $email
Groep: $Groep
Leeftijd: $Leeftijd
Opmerking:
$Opmerking
Einde bericht.
";
$headers = 'From: opgeven@kidsnthingspernis.nl' . "\r\n" .
'Reply-To: opgeven@kidsnthingspernis.nl' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email, $subject, $message, $headers);
?>
<?php
exit();
}
?>