Пример #1
0
<?php

/**
 * sagarpatel
 * Date: 31-Mar-15
 * Time: 3:12 PM
 */
include_once "../classes/_user.php";
$response = array('valid' => false, 'message' => 'Post argument "user" is missing.');
if (isset($_POST['username'])) {
    $requesting_username = $_POST['username'];
    $answer = _user::_check_existing_username($requesting_username);
    if ($answer) {
        // User name is registered on another account
        $response = array('valid' => false, 'message' => 'This username is already registered.');
    } else {
        // User name is available
        $response = array('valid' => true);
    }
}
echo json_encode($response);
Пример #2
0
 /**
  *  _check_form_data()
  *
  *  for checking the duplicates of object values into database
  *  & checks the password matching
  *
  *  returns:
  *  0 -> all correct
  *  1 -> username exist already
  *  2 -> email already exists
  *  3 -> password miss match
  *  4 -> username + email
  *  5 -> request all again
  */
 function _check_form_data()
 {
     $_check_email = _user::_check_existing_email($this->_email);
     $_check_username = _user::_check_existing_username($this->_username);
     $_check_password = $this->_password == $this->_confirmpassword;
     $c = _database::get_connection();
     echo $this->_username . ' ' . $this->_firstname . ' ' . $c->client_info . ' <br /> ';
     if (!$_check_email && !$_check_username && $_check_password) {
         return 0;
     }
     if ($_check_email && $_check_username) {
         return 4;
     }
     if ($_check_username) {
         return 1;
     }
     if ($_check_email) {
         return 2;
     }
     if (!$_check_password) {
         return 3;
     }
     return 5;
 }