}
}
$name = substr($_POST["name"], 0, 30);
$email = substr($_POST["email"], 0, 40);
$password = substr($_POST["password"], 0, 16);
$repassword = substr($_POST["repassword"], 0, 16);
$username = substr($_POST["username"], 0, 30);
$arr = array($name, $email, $password, $repassword, $username);
foreach ($arr as $value) {
    if ($value == "") {
        die("name cannot be empty");
    }
}
$valne = new validation();
$valne->name($name);
$valne->email($email);
$valne->username($username);
$con = new MongoClient();
if ($con) {
    $db = $con->{$users};
    $people = $db->{$myusers};
    $qry = array("email" => $email);
    $result = $people->findOne($qry);
    if ($result) {
        $success = "<div class='alert alert-warning'><strong>Alert !</strong> {$email} already exists </div>";
        echo $success;
        die;
    }
    $qry1 = array("username" => $username);
    $result1 = $people->findOne($qry1);
    if ($result1) {
Exemple #2
0
     if ($postType == 'register') {
         $usernameCheck = $database->requete("SELECT * FROM st_authentication WHERE matricule = '" . $matricule . "'");
         if (mysql_num_rows($usernameCheck) != 0) {
             $errMessagesArray["matricule"] = "Le matricule existe déjà";
             $isSubmissionValid = false;
         }
     }
 }
 // Password check
 if ($postType == "register" && (empty($password) || strlen($password) < MIN_PASSWORD_LENGTH)) {
     // Password must be between x-y characters
     $errMessagesArray["password"] = "******" . MIN_PASSWORD_LENGTH . " caractères";
     $isSubmissionValid = false;
 }
 // Email check
 if (empty($email) || !validation::email($email)) {
     $errMessagesArray["email"] = "Vous devez fournir une adresse courriel valide";
     $isSubmissionValid = false;
 } else {
     if (strcmp($email, $emailconf) != 0) {
         $errMessagesArray["emailconf"] = "Les deux adresses doivent êtres identiques";
         $isSubmissionValid = false;
     }
 }
 // Last name check
 if (empty($lastName)) {
     $errMessagesArray["lastName"] = "Vous devez fournir une valeur pour ce champ";
     $isSubmissionValid = false;
 }
 // First name check
 if (empty($firstName)) {