jqueryjsonjquery-form-validator

PHP to fetch JSON from JQUERY


I wanted to use server side validation by jQuery Form Validator. My understanding is there is an option to pass additional parameter to the server in form of JSON. The following snippet is from their website:

<?php 
  $json = json_encode(array('user'=>$user->get('ID'))); 
?>

<p>
  <strong>E-mail:</strong>
  <input type="email" 
         name="check-email" 
         data-validation="server" 
         data-validation-url="/validate-form-input.php" 
         data-validation-param-name="email" 
         data-validation-req-params="<?php echo $json ?>" />
</p>

Can anyone show me how to get the user ID in validate-form-input.php as per the code shown above? Thanks.


Solution

  • $user = $_POST['user'];
    

    I simply get it from $_POST.