コード例 #1
0
ファイル: Users.php プロジェクト: clagiordano/weblibs
function SaveUser($username, $password, $tipo, $stato, $db)
{
    if (ExistUser($username, $db) == 0) {
        $md5_pass = md5($password);
        $q_add_user = "******" . "('{$username}', '{$md5_pass}', '{$tipo}', '{$stato}')";
        $r_add_user = mysql_query($q_add_user, $db) or die(StampaErr($q_add_user));
        $msg = "<label class=\"ok\">Salvataggio effettuato correttamente.</label>";
        return $msg;
    } else {
        $msg = "<label class=\"err\">Errore, è già presente un utente con questo nome.</label>";
        return $msg;
    }
}
コード例 #2
0
ファイル: registration.php プロジェクト: picaso133/Tutorial
}
if (empty($_POST['password'])) {
    $errors['password'] = '******';
}
if (empty($_POST['password-confirm'])) {
    $errors['password-confirm'] = 'Confirm password is required';
}
if (!empty($_POST['password']) && !empty($_POST['confirm-password'])) {
    if ($_POST['password'] != $_POST['confirm-password']) {
        $errors['password'] = '******';
    }
}
// if there are any errors in our errors array, return a success boolean of false
if (!empty($errors)) {
    // if there are items in our errors array, return those errors
    $data['success'] = false;
    $data['errors'] = $errors;
} else {
    if (!ExistUser($bdd, $_POST['email'])) {
        $_SESSION['user_id'] = InsertNewUser($bdd, $_POST['email'], $_POST['password']);
        $newURL = ROOT_HOST . 'home';
        $data['success'] = true;
        $data['message'] = 'Success!';
        $data['url'] = $newURL;
    } else {
        $errors['user_exist'] = 'This email is already registered';
        $data['errors'] = $errors;
    }
}
header('Content-Type: application/json');
echo json_encode($data);