daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. if(empty($_POST["emailaddress"])){    
  4.     $error = 'true';
  5.     $validation_msg = 'Country missing.';
  6.     if(empty($error_msg)){
  7.         $error_msg .= $validation_msg;
  8.     } else{
  9.         $error_msg .= 'n' . $validation_msg;
  10.     }    
  11. }
  12.  
  13. if(empty($_POST["password"])){    
  14.     $error = 'true';
  15.     $validation_msg = 'Country missing.';
  16.     if(empty($error_msg)){
  17.         $error_msg .= $validation_msg;
  18.     } else{
  19.         $error_msg .= 'n' . $validation_msg;
  20.     }    
  21. }
  22.  
  23. if(empty($_POST["firstname"])){    
  24.     $error = 'true';
  25.     $validation_msg = 'First name missing.';
  26.     if(empty($error_msg)){
  27.         $error_msg .= $validation_msg;
  28.     } else{
  29.         $error_msg .= 'n' . $validation_msg;
  30.     }    
  31. }
  32.  
  33. if(empty($_POST["lastname"])){    
  34.     $error = 'true';
  35.     $validation_msg = 'Last name missing.';
  36.     if(empty($error_msg)){
  37.         $error_msg .= $validation_msg;
  38.     } else{
  39.         $error_msg .= 'n' . $validation_msg;
  40.     }    
  41. }
  42.  
  43. if($error){
  44.     header('HTTP/1.1 500 Internal Server Error');
  45.     header('Content-Type: application/json');
  46.     die($error_msg);
  47. }
  48.  
  49. ?>
  50.    
  51. $error_msg = '';
  52. foreach($_POST as $key => $val){
  53.     if(empty($val)){
  54.         $error = 'true';
  55.         $error_msg .= $key." missing.n";
  56.     }
  57. }
  58.    
  59. $error_msg = array()
  60.  
  61. if(empty($_POST["lastname"])){    
  62.     $error_msg[] = 'Last name missing.';
  63. }
  64.  
  65. ....
  66.  
  67. if($error_msg){
  68.     header('HTTP/1.1 500 Internal Server Error');
  69.     header('Content-Type: application/json');
  70.     die(implode("n", $error_msg);
  71. }
  72.    
  73. $error_msg = array();
  74.    
  75. $error_msg[] = $validation_msg;
  76.    
  77. if(count($error_msg) > 0){
  78.    
  79. <?php
  80. $array = new array{{"firstname","First Name"},{"lastname", "Last Name"}};
  81.    
  82. if(empty($_POST[$array[i][0])){               $error = 'true';           $validation_msg .= $array[i][1] ' missing.' . "n";
  83.    
  84. $msgStack = array();
  85.  
  86. function validate($field, $msg, $msgStack) {
  87.     if(empty($field)) {    
  88.         $error = 'true';
  89.         $msgStack[] = $msg;
  90.     }
  91. }
  92.    
  93. validate($_POST['firstname'], 'Firstname is empty', $msgStack);
  94.    
  95. echo implode(PHP_EOL, $msgStack);
  96.    
  97. if(empty($_POST["emailaddress"]) || empty($_POST["password"]) ||
  98.    empty($_POST["firstname"]) || empty($_POST["lastname"]) ){    
  99.     $error = TRUE;
  100.     if ( empty($_POST["emailaddress"]) )
  101.       $field = 'Email Address';
  102.    else  if ( empty($_POST["password"]) )
  103.       $field = 'Password';
  104.    else  if ( empty($_POST["firstname"]) )
  105.       $field = 'First Name';
  106.    else
  107.       $field = 'Last Name';
  108.  
  109.     $validation_msg = $field . ' missing.';
  110.     if(empty($error_msg)){
  111.     $error_msg .= $validation_msg;
  112.     } else{
  113.     $error_msg .= 'n' . $validation_msg;
  114.     }    
  115. }
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