Skip to content

Instantly share code, notes, and snippets.

@snowbob
Created October 18, 2015 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snowbob/bd9966b710254e45019a to your computer and use it in GitHub Desktop.
Save snowbob/bd9966b710254e45019a to your computer and use it in GitHub Desktop.
validatePage
<?php
include('../../../connect.php');
include('../../../plugins/GUMP-master/gump.class.php');
$ERROR=0;
$gump = new GUMP();
$_POST = $gump->sanitize($_POST); // You don't have to sanitize, but it's safest to do so.
$gump->validation_rules(array(
'name' => 'required|alpha|max_len,100|min_len,6',
//'password' => 'required|max_len,100|min_len,6',
'email' => 'required|valid_email'
//'gender' => 'required|exact_len,1|contains,m f',
// 'credit_card' => 'required|valid_cc'
));
$gump->filter_rules(array(
'name' => 'trim|sanitize_string',
// 'password' => 'trim',
'email' => 'trim|sanitize_email'
//'gender' => 'trim',
//'bio' => 'noise_words'
));
$validated_data = $gump->run($_POST);
if($validated_data === false) {
$error_msg = $gump->get_readable_errors(true);
$ERROR=0;
} else {
if ($_POST['name']!='') {
$ERROR = 1;
}
}
if ($ERROR == '1') {
echo json_encode(array(
'status' => 'success',
'message'=> 'success message'
));
}
else
{
echo json_encode(array(
'status' => 'error',
'message'=> $error_msg
));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment