fbpx
<?php <!-- [et_pb_line_break_holder] -->if (isset($_REQUEST['submitted'])) {<!-- [et_pb_line_break_holder] -->// Initialize error array.<!-- [et_pb_line_break_holder] --> $errors = array();<!-- [et_pb_line_break_holder] --> // Check for a proper First name<!-- [et_pb_line_break_holder] --> if (!empty($_REQUEST['firstname'])) {<!-- [et_pb_line_break_holder] --> $firstname = $_REQUEST['firstname'];<!-- [et_pb_line_break_holder] --> $pattern = "/^[a-zA-Z0-9\_]{2,20}/";// This is a regular expression that checks if the name is valid characters<!-- [et_pb_line_break_holder] --> if (preg_match($pattern,$firstname)){ $firstname = $_REQUEST['firstname'];}<!-- [et_pb_line_break_holder] --> else{ $errors[] = 'Your Name can only contain _, 1-9, A-Z or a-z 2-20 long.';}<!-- [et_pb_line_break_holder] --> } else {$errors[] = 'You forgot to enter your First Name.';}<!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] --> // Check for a proper Last name<!-- [et_pb_line_break_holder] --> if (!empty($_REQUEST['lastname'])) {<!-- [et_pb_line_break_holder] --> $lastname = $_REQUEST['lastname'];<!-- [et_pb_line_break_holder] --> $pattern = "/^[a-zA-Z0-9\_]{2,20}/";// This is a regular expression that checks if the name is valid characters<!-- [et_pb_line_break_holder] --> if (preg_match($pattern,$lastname)){ $lastname = $_REQUEST['lastname'];}<!-- [et_pb_line_break_holder] --> else{ $errors[] = 'Your Name can only contain _, 1-9, A-Z or a-z 2-20 long.';}<!-- [et_pb_line_break_holder] --> } else {$errors[] = 'You forgot to enter your Last Name.';}<!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] --> //Check for a valid phone number<!-- [et_pb_line_break_holder] --> if (!empty($_REQUEST['phone'])) {<!-- [et_pb_line_break_holder] --> $phone = $_REQUEST['phone'];<!-- [et_pb_line_break_holder] --> $pattern = "/^[0-9\_]{7,20}/";<!-- [et_pb_line_break_holder] --> if (preg_match($pattern,$phone)){ $phone = $_REQUEST['phone'];}<!-- [et_pb_line_break_holder] --> else{ $errors[] = 'Your Phone number can only be numbers.';}<!-- [et_pb_line_break_holder] --> } else {$errors[] = 'You forgot to enter your Phone number.';}<!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] --> if (!empty($_REQUEST['redmapleacer']) || !empty($_REQUEST['chinesepistache']) || !empty($_REQUEST['raywoodash'])) {<!-- [et_pb_line_break_holder] --> $check1 = $_REQUEST['redmapleacer'];<!-- [et_pb_line_break_holder] --> if (empty($check1)){$check1 = 'Unchecked';}else{$check1 = 'Checked';}<!-- [et_pb_line_break_holder] --> $check2 = $_REQUEST['chinesepistache'];<!-- [et_pb_line_break_holder] --> if (empty($check2)){$check2 = 'Unchecked';}else{$check2 = 'Checked';}<!-- [et_pb_line_break_holder] --> $check3 = $_REQUEST['raywoodash'];<!-- [et_pb_line_break_holder] --> if (empty($check3)){$check3 = 'Unchecked';}else{$check3 = 'Checked';}<!-- [et_pb_line_break_holder] --> } else {$errors[] = 'You forgot to enter your Phone number.';}<!-- [et_pb_line_break_holder] --> }<!-- [et_pb_line_break_holder] --> //End of validation