Skip to content

Instantly share code, notes, and snippets.

@rantastic
Created March 21, 2013 18:36
Show Gist options
  • Save rantastic/5215512 to your computer and use it in GitHub Desktop.
Save rantastic/5215512 to your computer and use it in GitHub Desktop.
PHP: Post validate
foreach($_POST as $key => $value){
switch($key){
case $key == 'email':
if ($value == ''){
$data['error'][] = array($key,'Enter your email');
}
else{
if (!filter_var($value, FILTER_VALIDATE_EMAIL)){
$data['error'][] = array($key,'Enter a valid email');
}
}
break;
case $key == 'password':
if ($value == ''){
$data['error'][]= array($key,'Enter a password');
}
break;
}
}
if(!array_key_exists('error',$data)){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment