3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "emdheide@upcmail.nl"; $email_subject = "Vraag binnengekomen via website"; function died($error) { // your error code can go here echo "Er zijn fouten ontdekt bij het invullen van het formulier. "; echo "Deze fouten zijn.<br /><br />"; echo $error."<br /><br />"; echo "Ga terug en probeer het opnieuw.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['bname']) || !isset($_POST['tel']) || !isset($_POST['email']) || !isset($_POST['textarea'])) { died('Het spijt ons, het lijkt dat er een probleem is met het formulier dat u hebt verzonden.'); } $name = $_POST['name']; // required $bname = $_POST['bname']; // required $tel = $_POST['tel']; // required $email = $_POST['email']; // not required $textarea = $_POST['textarea']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email)) { $error_message .= 'Het Email Adres klopt niet.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$name)) { $error_message .= 'Vul uw Naam in.<br />'; } if(!preg_match($string_exp,$bname)) { $error_message .= 'Vul uw Bedrijfsnaam in.<br />'; } if(strlen($textarea) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Naam: ".clean_string($name)."\n"; $email_message .= "Bedrijf: ".clean_string($bname)."\n"; $email_message .= "Telefoon: ".clean_string($tel)."\n"; $email_message .= "Email: ".clean_string($email)."\n"; $email_message .= "Vraag: ".clean_string($textarea)."\n"; // create email headers @mail($email_to, $email_subject, $email_message); header('Location:bedankt.html'); exit(); ?> <!-- include your own success html here --> <?php } ?>
based on tcBB8
Output for 4.3.0 - 7.1.0