remote.php 809 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. // This is a sample PHP script which demonstrates the 'remote' validator
  3. // To make it work, point the web server to root Bootstrap Validate directory
  4. // and open the remote.html file:
  5. // http://domain.com/demo/remote.html
  6. header('Content-type: application/json');
  7. //sleep(5);
  8. $valid = true;
  9. $users = array(
  10. 'admin' => 'admin@domain.com',
  11. 'administrator' => 'administrator@domain.com',
  12. 'root' => 'root@domain.com',
  13. );
  14. if (isset($_POST['username']) && array_key_exists($_POST['username'], $users)) {
  15. $valid = false;
  16. } else if (isset($_POST['email'])) {
  17. $email = $_POST['email'][0];
  18. foreach ($users as $k => $v) {
  19. if ($email == $v) {
  20. $valid = false;
  21. break;
  22. }
  23. }
  24. }
  25. echo json_encode(array(
  26. 'valid' => $valid,
  27. ));