/ Published in: PHP
Expand |
Embed | Plain Text
<?php if($_SERVER['REQUEST_METHOD'] == 'POST') { # If the form is send { # If $_POST['name'] is empty $error[] = 'Je hebt geen naam ingevuld'; } { # If $_POST['email'] is empty $error[] = 'Je hebt geen of een foute email ingevuld'; } { # If there are no errors $post = 'Hello Webmaster'."\n"; $post .= 'Name: '.$_POST['name']."\n"; // Geef GELDIGE adressen op // A short description of you're site $site_name = 'Mijn Site'; // You're email $own_emailadres = 'mijn_emailadres@mijn_domein.nl'; // A good email for errors $error_emailadres = 'mijn_emailadres@mijn_domein.nl'; // The name pf person who we send the mail to $name_sender = 'Afzender'; // The mail of person who we send the mail to $email_sender = 'emailadres_van_verzender@zijn_domein.nl'; // Fill in a good emailadres or make it empty $bcc_email = 'geldig_emailadres@geldig_domein.nl'; // HTML mail? True/False $html = true; // Make up de headers $headers = 'From: ' . $site_name . ' <' . $own_emailadres . '>' . PHP_EOL; $headers .= 'Reply-To: ' . $naam_sender . ' <' . $email_sender . '>' . PHP_EOL; $headers .= 'Return-Path: Mail-Error <' . $error_emailadres . '>' . PHP_EOL; $headers .= ($bcc_emailadres != '') ? 'Bcc: ' . $bcc_emailadres . PHP_EOL : ''; $headers .= 'X-Priority: Normal' . PHP_EOL; $headers .= ($html) ? 'MIME-Version: 1.0' . PHP_EOL : ''; $headers .= ($html) ? 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL : ''; // Send the mail // The first parameter is the email to send to. The second is the subject // and the tirth is the post (who we have set up above) and the last the // headers (who we've set up) } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="nl"> <head> <title>Formulier verwerking</title> </head> <body> <?php { # Als $error niet leeg is foreach($error as $e) { # Voor elke error } } ?> <form action="" method="post"> <label>Naam: <input type="text" name="name"></label><br /> <label>Email: <input type="text" name="email"></label><br /> <input type="submit" value="verzenden"> </form> </body> </html>
You need to login to post a comment.
