3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //create short variable names $phonee=$_POST['Phone']; $nn="[a-zA-Z]"; $honda=1; $name = check_input($_POST['FirstName']); //run check_input function all all incoming data $fromEmail = check_input($_POST['Email']); $toaddress = "kcambridge@est-static.com"; //INITIAL VALIDATION //Function checks input and strips potential dangerous characters so injection code cannot be //interpereted correctly function check_input($data) { $data = trim($data); // strips any quotes escaped with slashes $data = stripslashes($data); //strips slashes $data = htmlspecialchars($data); //replaces HTML characters like > with HTML version &lt; return $data; } function isEmailValid($fromEmail) { $pattern = "^[_a-z0-9.-]+(\._a-z0-9.-+)*@[a-z0-9.-]+(\.[a-z0-9.-]+)*(\.[a-z]{2,3})$"; if (eregi($pattern,$fromEmail)) { //eregi - case insensitive regular expression match return true; } else { return false; } } //FORM SUBMISSION VALIDATION //Scipt checks for new line characters like "\r" or "\n" which allows spam to create a new line //in email headers. If these characters are found return ERROR if (((!isEmailValid($fromEmail)) || ($fromEmail == "")|| (strlen($_POST["Phone"]) < 10 ) || preg_match("/$nn/",$phonee))) { echo "Error - From email address is Invalid or has been left blank or Phone number is not valid." . "<br/><br/>" . "Please return to form and re-enter a valid Email Address or phone number." . "<br/><br/>"; } else { $to = "kcambridge@est-static.com"; $subject = "Aegis Newsletter Signup"; $from = $_POST['Email']; $message =''. " \n"; foreach($_POST as $name => $data) { if(is_array($data)) { foreach($data as $datum) $message .= $name . ": " . $datum . " \n"; } else $message .= $name . ": " . $data . " \n"; } # Attempt to send email if(mail($to, $subject, $message, "From: $fromEmail")) header('location:thanks.htm'); else echo "Mail send failure - message not sent";} ?>
Output for 7.0.0 - 7.1.0
Notice: Undefined index: Phone in /in/cn9nN on line 3 Notice: Undefined index: FirstName in /in/cn9nN on line 6 Notice: Undefined index: Email in /in/cn9nN on line 7 Fatal error: Uncaught Error: Call to undefined function eregi() in /in/cn9nN:22 Stack trace: #0 /in/cn9nN(36): isEmailValid('') #1 {main} thrown in /in/cn9nN on line 22
Process exited with code 255.
Output for 5.3.0 - 5.6.28
Notice: Undefined index: Phone in /in/cn9nN on line 3 Notice: Undefined index: FirstName in /in/cn9nN on line 6 Notice: Undefined index: Email in /in/cn9nN on line 7 Deprecated: Function eregi() is deprecated in /in/cn9nN on line 22 Error - From email address is Invalid or has been left blank or Phone number is not valid.<br/><br/>Please return to form and re-enter a valid Email Address or phone number.<br/><br/>
Output for 4.3.0 - 5.2.17
Notice: Undefined index: Phone in /in/cn9nN on line 3 Notice: Undefined index: FirstName in /in/cn9nN on line 6 Notice: Undefined index: Email in /in/cn9nN on line 7 Error - From email address is Invalid or has been left blank or Phone number is not valid.<br/><br/>Please return to form and re-enter a valid Email Address or phone number.<br/><br/>