3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(E_ALL ^ E_NOTICE); // require a name from user if(trim($_POST['contactName']) === '') { $nameError = 'Forgot your name!'; $hasError = true; } else { $name = trim($_POST['contactName']); } // need valid email if(trim($_POST['email']) === '') { $emailError = 'Forgot to enter in your e-mail address.'; $hasError = true; } else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure that the name field is not empty if(trim($_POST['weburl']) == '') { $hasError = false; } else { $weburl = trim($_POST['weburl']); } // we need at least some content if(trim($_POST['comments']) === '') { $commentError = 'You forgot to enter a message!'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['comments'])); } else { $comments = trim($_POST['comments']); } } // upon no failure errors let's email now! if(!isset($hasError)) { $emailTo = 'blabla@gmail.com'; $subject = 'For Radikal Grafix from '.$name; $sendCopy = trim($_POST['sendCopy']); $body = "Name: $name \n\nEmail: $email \n\nWeburl: $weburl \n\nComments: $comments"; $headers = 'From: ' .' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); // set our boolean completion value to TRUE $emailSent = true; } ?> <script src="https://code.jquery.com/jquery-1.11.0.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> <script src="http://rawgithub.com/mingliangfeng/jquery.validate.bootstrap.popover/master/dist/jquery.validate.bootstrap.popover.min.js"></script> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"/> <script> $(document).ready(function() { $("#contactForm").validate_popover({ errorClass: "has-error", highlight: function(label) { $(label).closest('.control-group').removeClass('has-success').addClass('has-error'); }, successClass: "has-success", unhighlight:function(label) { $(label).closest('.control-group').text('OK!').addClass('has-success'); }, rules: { contactName: { required: true }, email: { required: true, email: true }, weburl: { required: false, url : true }, comments: { required: true, maxlength: 200 } }, }); $("#contactform").on("submit", function(event){ event.preventDefault; $.ajax({ type: "POST", url: "about.php", data: $("#contactForm").serialize() }).done(function( msg ) { var formInput = $(this).serialize(); $.post($(this).attr('action'),formInput,function(data){ $("#myAccordion").slideUp("slow"); $(this).before('<p class="thanx">thanx! talk soon.</p>'); }); }); return false; }); }); </script> <div class="col-lg-4 col-md-4 col-sm-4 col-xs-10-offset-1"> <div id="myAccordion" class="accordion center"> <div class="accordion-group"> <div class="accordion-heading"> <a href="#collapseOne" data-parent="#myAccordion" id="open" data-toggle="collapse" class="accordion-toggle btn btn-custom contacts" role="button">contact</a> </div> </div> <div class="accordion-body collapse center" id="collapseOne"> <div class="accordion-inner center"> <form role="form" class="form-inline center" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactForm"> <div id="results"> <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?> <div class=" alert-success"> <p class="thanx">Thanx! Talk soon!</p> </div> <?php } ?> <?php if(isset($hasError) || isset($captchaError) ) { ?> <p class="alert">Error submitting the form</p> <?php } ?> </div> <fieldset> <div class="form-group"> <label for="contactName" class="sr-only">Your Full Name:</label> <div class="control-group"> <input type="text" name="contactName" id="contactName" value="" class="required form-control" role="input" placeholder="Your Full Name:" /> </div> </div> <div class="form-group"> <label for="email" class="sr-only">Your Email</label> <div class="control-group"> <input type="text" name="email" id="email" value="" class="required form-control email" role="input" placeholder="Email:" /> </div> </div> <div class="form-group"> <label for="weburl" class="sr-only">Your Website</label> <div class="control-group"> <input type="text" name="weburl" id="weburl" value="" class="form-control url" role="input" aria-required="false" placeholder="Website: (optional)"/> </div> </div> <div class="form-group"> <label for="comments" class="sr-only">Message</label> <div class="control-group"> <textarea rows="6" name="message" id="comments" class=" required form-control comments" role="textbox" rel="popover" placeholder="Message:"></textarea> </div> </div> <div class="form-group actions col-md-6 col-sm-6"> <div class="col-md-2 col-md-offset-1 col-sm-2 col-sm-offset-1"> <a href="#collapseOne" data-parent="#myAccordion" id="close" data-toggle="collapse" class="accordion-toggle btn btn-custom sub" role="button">close</a> </div> <div class="col-md-2 col-md-offset-3 col-sm-3 col-sm-offset-2"> <button id="submit" class="btn btn-custom center sub" type="submit">Submit</button> <input type="hidden" name="submitted" id="submitted" value="true" /> </div> </div> </fieldset> </form> </div><!--end accord inner --> </div><!-- end #collapseOne--> </div><!-- end #myAccord--> </div><!--end col-lg-4-->
Output for 5.2.3 - 5.6.28, hhvm-3.10.0, 7.0.0 - 7.1.0
<script src="https://code.jquery.com/jquery-1.11.0.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> <script src="http://rawgithub.com/mingliangfeng/jquery.validate.bootstrap.popover/master/dist/jquery.validate.bootstrap.popover.min.js"></script> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"/> <script> $(document).ready(function() { $("#contactForm").validate_popover({ errorClass: "has-error", highlight: function(label) { $(label).closest('.control-group').removeClass('has-success').addClass('has-error'); }, successClass: "has-success", unhighlight:function(label) { $(label).closest('.control-group').text('OK!').addClass('has-success'); }, rules: { contactName: { required: true }, email: { required: true, email: true }, weburl: { required: false, url : true }, comments: { required: true, maxlength: 200 } }, }); $("#contactform").on("submit", function(event){ event.preventDefault; $.ajax({ type: "POST", url: "about.php", data: $("#contactForm").serialize() }).done(function( msg ) { var formInput = $(this).serialize(); $.post($(this).attr('action'),formInput,function(data){ $("#myAccordion").slideUp("slow"); $(this).before('<p class="thanx">thanx! talk soon.</p>'); }); }); return false; }); }); </script> <div class="col-lg-4 col-md-4 col-sm-4 col-xs-10-offset-1"> <div id="myAccordion" class="accordion center"> <div class="accordion-group"> <div class="accordion-heading"> <a href="#collapseOne" data-parent="#myAccordion" id="open" data-toggle="collapse" class="accordion-toggle btn btn-custom contacts" role="button">contact</a> </div> </div> <div class="accordion-body collapse center" id="collapseOne"> <div class="accordion-inner center"> <form role="form" class="form-inline center" method="post" action="/in/RjZr3" id="contactForm"> <div id="results"> <p class="alert">Error submitting the form</p> </div> <fieldset> <div class="form-group"> <label for="contactName" class="sr-only">Your Full Name:</label> <div class="control-group"> <input type="text" name="contactName" id="contactName" value="" class="required form-control" role="input" placeholder="Your Full Name:" /> </div> </div> <div class="form-group"> <label for="email" class="sr-only">Your Email</label> <div class="control-group"> <input type="text" name="email" id="email" value="" class="required form-control email" role="input" placeholder="Email:" /> </div> </div> <div class="form-group"> <label for="weburl" class="sr-only">Your Website</label> <div class="control-group"> <input type="text" name="weburl" id="weburl" value="" class="form-control url" role="input" aria-required="false" placeholder="Website: (optional)"/> </div> </div> <div class="form-group"> <label for="comments" class="sr-only">Message</label> <div class="control-group"> <textarea rows="6" name="message" id="comments" class=" required form-control comments" role="textbox" rel="popover" placeholder="Message:"></textarea> </div> </div> <div class="form-group actions col-md-6 col-sm-6"> <div class="col-md-2 col-md-offset-1 col-sm-2 col-sm-offset-1"> <a href="#collapseOne" data-parent="#myAccordion" id="close" data-toggle="collapse" class="accordion-toggle btn btn-custom sub" role="button">close</a> </div> <div class="col-md-2 col-md-offset-3 col-sm-3 col-sm-offset-2"> <button id="submit" class="btn btn-custom center sub" type="submit">Submit</button> <input type="hidden" name="submitted" id="submitted" value="true" /> </div> </div> </fieldset> </form> </div><!--end accord inner --> </div><!-- end #collapseOne--> </div><!-- end #myAccord--> </div><!--end col-lg-4-->
Output for hhvm-3.12.0 - 3.13.2
Warning: trim() expects parameter 1 to be string, null given in /in/RjZr3 on line 6 Warning: trim() expects parameter 1 to be string, null given in /in/RjZr3 on line 10 Warning: trim() expects parameter 1 to be string, null given in /in/RjZr3 on line 14 Warning: trim() expects parameter 1 to be string, null given in /in/RjZr3 on line 17 Warning: preg_match() expects parameter 2 to be string, null given in /in/RjZr3 on line 17 Warning: trim() expects parameter 1 to be string, null given in /in/RjZr3 on line 25 Warning: trim() expects parameter 1 to be string, null given in /in/RjZr3 on line 31 Warning: trim() expects parameter 1 to be string, null given in /in/RjZr3 on line 36 Warning: stripslashes() expects parameter 1 to be string, null given in /in/RjZr3 on line 36 <script src="https://code.jquery.com/jquery-1.11.0.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> <script src="http://rawgithub.com/mingliangfeng/jquery.validate.bootstrap.popover/master/dist/jquery.validate.bootstrap.popover.min.js"></script> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"/> <script> $(document).ready(function() { $("#contactForm").validate_popover({ errorClass: "has-error", highlight: function(label) { $(label).closest('.control-group').removeClass('has-success').addClass('has-error'); }, successClass: "has-success", unhighlight:function(label) { $(label).closest('.control-group').text('OK!').addClass('has-success'); }, rules: { contactName: { required: true }, email: { required: true, email: true }, weburl: { required: false, url : true }, comments: { required: true, maxlength: 200 } }, }); $("#contactform").on("submit", function(event){ event.preventDefault; $.ajax({ type: "POST", url: "about.php", data: $("#contactForm").serialize() }).done(function( msg ) { var formInput = $(this).serialize(); $.post($(this).attr('action'),formInput,function(data){ $("#myAccordion").slideUp("slow"); $(this).before('<p class="thanx">thanx! talk soon.</p>'); }); }); return false; }); }); </script> <div class="col-lg-4 col-md-4 col-sm-4 col-xs-10-offset-1"> <div id="myAccordion" class="accordion center"> <div class="accordion-group"> <div class="accordion-heading"> <a href="#collapseOne" data-parent="#myAccordion" id="open" data-toggle="collapse" class="accordion-toggle btn btn-custom contacts" role="button">contact</a> </div> </div> <div class="accordion-body collapse center" id="collapseOne"> <div class="accordion-inner center"> <form role="form" class="form-inline center" method="post" action="/in/RjZr3" id="contactForm"> <div id="results"> <p class="alert">Error submitting the form</p> </div> <fieldset> <div class="form-group"> <label for="contactName" class="sr-only">Your Full Name:</label> <div class="control-group"> <input type="text" name="contactName" id="contactName" value="" class="required form-control" role="input" placeholder="Your Full Name:" /> </div> </div> <div class="form-group"> <label for="email" class="sr-only">Your Email</label> <div class="control-group"> <input type="text" name="email" id="email" value="" class="required form-control email" role="input" placeholder="Email:" /> </div> </div> <div class="form-group"> <label for="weburl" class="sr-only">Your Website</label> <div class="control-group"> <input type="text" name="weburl" id="weburl" value="" class="form-control url" role="input" aria-required="false" placeholder="Website: (optional)"/> </div> </div> <div class="form-group"> <label for="comments" class="sr-only">Message</label> <div class="control-group"> <textarea rows="6" name="message" id="comments" class=" required form-control comments" role="textbox" rel="popover" placeholder="Message:"></textarea> </div> </div> <div class="form-group actions col-md-6 col-sm-6"> <div class="col-md-2 col-md-offset-1 col-sm-2 col-sm-offset-1"> <a href="#collapseOne" data-parent="#myAccordion" id="close" data-toggle="collapse" class="accordion-toggle btn btn-custom sub" role="button">close</a> </div> <div class="col-md-2 col-md-offset-3 col-sm-3 col-sm-offset-2"> <button id="submit" class="btn btn-custom center sub" type="submit">Submit</button> <input type="hidden" name="submitted" id="submitted" value="true" /> </div> </div> </fieldset> </form> </div><!--end accord inner --> </div><!-- end #collapseOne--> </div><!-- end #myAccord--> </div><!--end col-lg-4-->
Output for 4.3.0 - 5.2.2
<script src="https://code.jquery.com/jquery-1.11.0.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> <script src="http://rawgithub.com/mingliangfeng/jquery.validate.bootstrap.popover/master/dist/jquery.validate.bootstrap.popover.min.js"></script> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"/> <script> $(document).ready(function() { $("#contactForm").validate_popover({ errorClass: "has-error", highlight: function(label) { $(label).closest('.control-group').removeClass('has-success').addClass('has-error'); }, successClass: "has-success", unhighlight:function(label) { $(label).closest('.control-group').text('OK!').addClass('has-success'); }, rules: { contactName: { required: true }, email: { required: true, email: true }, weburl: { required: false, url : true }, comments: { required: true, maxlength: 200 } }, }); $("#contactform").on("submit", function(event){ event.preventDefault; $.ajax({ type: "POST", url: "about.php", data: $("#contactForm").serialize() }).done(function( msg ) { var formInput = $(this).serialize(); $.post($(this).attr('action'),formInput,function(data){ $("#myAccordion").slideUp("slow"); $(this).before('<p class="thanx">thanx! talk soon.</p>'); }); }); return false; }); }); </script> <div class="col-lg-4 col-md-4 col-sm-4 col-xs-10-offset-1"> <div id="myAccordion" class="accordion center"> <div class="accordion-group"> <div class="accordion-heading"> <a href="#collapseOne" data-parent="#myAccordion" id="open" data-toggle="collapse" class="accordion-toggle btn btn-custom contacts" role="button">contact</a> </div> </div> <div class="accordion-body collapse center" id="collapseOne"> <div class="accordion-inner center"> <form role="form" class="form-inline center" method="post" action="" id="contactForm"> <div id="results"> <p class="alert">Error submitting the form</p> </div> <fieldset> <div class="form-group"> <label for="contactName" class="sr-only">Your Full Name:</label> <div class="control-group"> <input type="text" name="contactName" id="contactName" value="" class="required form-control" role="input" placeholder="Your Full Name:" /> </div> </div> <div class="form-group"> <label for="email" class="sr-only">Your Email</label> <div class="control-group"> <input type="text" name="email" id="email" value="" class="required form-control email" role="input" placeholder="Email:" /> </div> </div> <div class="form-group"> <label for="weburl" class="sr-only">Your Website</label> <div class="control-group"> <input type="text" name="weburl" id="weburl" value="" class="form-control url" role="input" aria-required="false" placeholder="Website: (optional)"/> </div> </div> <div class="form-group"> <label for="comments" class="sr-only">Message</label> <div class="control-group"> <textarea rows="6" name="message" id="comments" class=" required form-control comments" role="textbox" rel="popover" placeholder="Message:"></textarea> </div> </div> <div class="form-group actions col-md-6 col-sm-6"> <div class="col-md-2 col-md-offset-1 col-sm-2 col-sm-offset-1"> <a href="#collapseOne" data-parent="#myAccordion" id="close" data-toggle="collapse" class="accordion-toggle btn btn-custom sub" role="button">close</a> </div> <div class="col-md-2 col-md-offset-3 col-sm-3 col-sm-offset-2"> <button id="submit" class="btn btn-custom center sub" type="submit">Submit</button> <input type="hidden" name="submitted" id="submitted" value="true" /> </div> </div> </fieldset> </form> </div><!--end accord inner --> </div><!-- end #collapseOne--> </div><!-- end #myAccord--> </div><!--end col-lg-4-->