SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4. $errors = [
  5.     "errorUserName" => "",
  6.     "errorUserForname" => "",
  7.     "errorEmail" => "",
  8.     "errorPhone" => "",
  9.     "errorSubject" => "",
  10.     "errorMessage" => "",
  11. ];
  12. $validation=false;
  13. if($_SERVER["REQUEST_METHOD"] == "POST"){
  14.     $userName = $_POST[('userName')];
  15.     $userForname = $_POST[('userForname')];
  16.     $email = $_POST[('email')];
  17.     $phone = $_POST[('phone')];
  18.     $subject = $_POST[('subject')];
  19.     $message = $_POST[('message')];
  20.  
  21. if(empty($userName)){
  22.     $errors["errorUserName"]= "<small> Vous n'avez pas renseigné votre nom</small>";
  23. } elseif (!preg_match("/^[a-zA-Z ]*$/", $userName)) {
  24.     $errors["errorUserName"] = "<small>Only letters and white space allowed</small>";
  25. }
  26.  
  27.  
  28.   if(empty($userForname)){
  29.     $errors["errorUserForname"]= "<small> Vous n'avez pas renseigné votre prénom</small>";
  30. }elseif (!preg_match("/^[a-zA-Z ]*$/", $userForname)) {
  31.       $errors["errorUserForname"] = "<small>Entrez un nom valide</small>";
  32.   }
  33.  
  34. if(empty($email)){
  35.     $errors["errorEmail"]= "<small> Vous n'avez pas renseigné votre email</small>";
  36. }elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  37.     $errors["errorEmail"] = "<small>Entrez un mail valide</small>";
  38. }
  39. if(empty($phone)){
  40.     $errors["errorPhone"]= "<small> Vous n'avez pas renseigné votre téléphone</small>";
  41. }elseif (!preg_match("/^[0-9]*10/", $phone)) {
  42.     $errors["errorPhone"] = "<small>Entrez un numéro de téléphone valide</small>";
  43. }
  44. if(empty($subject)){
  45.     $errors["errorSubject"]= "<small> Vous n'avez pas renseigné d'option</small>";
  46. }
  47. if(empty($message)){
  48.     $errors["errorMessage"]= "<small> Vous n'avez pas renseigné de message</small>";
  49. }
  50.  
  51. if ($errors['errorUserName']== "" && $errors['errorUserForname']== "" && $errors['errorEmail']== "" && $errors['errorPhone']== "" && $errors['errorSubject']== "" && $errors['errorMessage']== ""){
  52.     $validation = true;
  53. }
  54. if($validation==true){
  55.     header('Location: success.php');
  56. }
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top