Created
October 18, 2015 15:17
-
-
Save snowbob/bd9966b710254e45019a to your computer and use it in GitHub Desktop.
validatePage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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