Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ($_POST) {
- $errors = array();
- if (empty($_POST["userName"])) {
- $errors["userName"] = "Name is required";
- }
- if(strlen($_POST['userName']) < 2 || strlen($_POST['userName']) > 32) {
- $errors['userName'] = "Name must be at least between 2 and 30 characters long";
- }
- if (!preg_match('#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#',$_POST['userEmail'])) {
- $errors["userEmail"] = "Valid email adress is required";
- }
- if (!preg_match("#^0[1-9]([-. ]?[0-9]{2}){4}$#", $_POST["userPhone"])) {
- $errors["userPhone"] = "Valid phone number is required";
- }
- if (empty($_POST["userReason"])) {
- $errors["userReason"] = "Please select the reason of your message";
- }
- if (empty($_POST["userMessage"])) {
- $errors["userMessage"] = "Please enter your message";
- }
- if(strlen($_POST['userMessage']) < 2 || strlen($_POST['userMessage']) > 600) {
- $errors['userMessage'] = "Message must be at least between 2 and 600 characters long";
- }
- if(count($errors) == 0) {
- unset($_POST);
- echo "<strong>Succes</strong>";
- }
- }
Add Comment
Please, Sign In to add comment