remote.php 761 B

12345678910111213141516171819202122232425262728293031
  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. sleep(5);
  7. $valid = true;
  8. $users = array(
  9. 'admin' => 'admin@domain.com',
  10. 'administrator' => 'administrator@domain.com',
  11. 'root' => 'root@domain.com',
  12. );
  13. if (isset($_POST['username']) && array_key_exists($_POST['username'], $users)) {
  14. $valid = false;
  15. } else if (isset($_POST['email'])) {
  16. $email = $_POST['email'];
  17. foreach ($users as $k => $v) {
  18. if ($email == $v) {
  19. $valid = false;
  20. break;
  21. }
  22. }
  23. }
  24. echo json_encode(array(
  25. 'valid' => $valid,
  26. ));