fork download
  1. <?php
  2.  
  3. // your code goes here
  4. $first_name = '3432'; // required
  5. $last_name = 'name'; // required
  6. $email_from = 'test@email.com'; // required
  7. $comments = 'Comments'; // required
  8.  
  9. $error_message = "";
  10. $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  11. if(!preg_match($email_exp,$email_from)) {
  12. $error_message .= 'The Email Address you entered does not appear to be valid.<br />';}
  13. $string_exp = "/^[A-Za-z .'-]+$/";
  14. if(!preg_match($string_exp,$first_name)) {
  15. $error_message .= 'The First Name you entered does not appear to be valid.<br />';}
  16. if(!preg_match($string_exp,$last_name)) {
  17. $error_message .= 'The Last Name you entered does not appear to be valid.<br />';}
  18. if(strlen($comments) < 2) {
  19. $error_message .= 'The Comments you entered do not appear to be valid.<br />';}
  20. if(strlen($error_message) > 0) {
  21. exit($error_message);
  22. } else {
  23. echo 'valid';
  24. }
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
The First Name you entered does not appear to be valid.<br />