當前位置: 首頁>>代碼示例>>PHP>>正文


PHP USER::email_exists方法代碼示例

本文整理匯總了PHP中USER::email_exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP USER::email_exists方法的具體用法?PHP USER::email_exists怎麽用?PHP USER::email_exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在USER的用法示例。


在下文中一共展示了USER::email_exists方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array

include_once '../../../includes/easyparliament/init.php';
$this_page = "userpassword";
$PAGE->page_start();
$PAGE->stripe_start();
if (get_http_var("submitted")) {
    // Form's been submitted.
    // Where we'll store any errors that occur...
    $errors = array();
    $email = trim(get_http_var("email"));
    if ($email == "") {
        $errors["email"] = "Please enter your email address";
    } elseif (!validate_email($email)) {
        $errors["email"] = "Please enter a valid email address";
    } else {
        $USER = new USER();
        $emailexists = $USER->email_exists($email);
        if (!$emailexists) {
            $errors["email"] = 'There is no user registered with that email address. If you are subscribed to email alerts, you are not necessarily registered on the website. If you register, you will be able to manage your email alerts, as well as leave annotations.';
        }
    }
    if (sizeof($errors) > 0) {
        // Validation errors. Print form again.
        display_page($errors);
    } else {
        // Change the user's password!
        $password = $USER->change_password($email);
        if ($password) {
            $success = $USER->send_password_reminder();
            if ($success) {
                print "<p>A new password has been sent to " . _htmlentities($email) . "</p>\n";
            } else {
開發者ID:udp12,項目名稱:theyworkforyou,代碼行數:31,代碼來源:index.php

示例2: check_input

function check_input($details)
{
    global $THEUSER, $this_page, $who;
    // This may be a URL that will send the user back to where they were before they
    // wanted to join.
    $ret = get_http_var("ret");
    $errors = array();
    // Check each of the things the user has input.
    // If there is a problem with any of them, set an entry in the $errors array.
    // This will then be used to (a) indicate there were errors and (b) display
    // error messages when we show the form again.
    // Check first name.
    if ($details["firstname"] == "") {
        $errors["firstname"] = "Please enter {$who} first name";
    }
    // They don't need a last name. In case Madonna joins.
    // Check email address is valid and unique.
    if ($details["email"] == "") {
        $errors["email"] = "Please enter {$who} email address";
    } elseif (!validate_email($details["email"])) {
        // validate_email() is in includes/utilities.php
        $errors["email"] = "Please enter a valid email address";
    } else {
        $USER = new USER();
        $id_of_user_with_this_addresss = $USER->email_exists($details["email"]);
        if ($this_page == "useredit" && get_http_var("u") == "" && $THEUSER->isloggedin()) {
            // User is updating their own info.
            // Check no one else has this email.
            if ($id_of_user_with_this_addresss && $id_of_user_with_this_addresss != $THEUSER->user_id()) {
                $errors["email"] = "Someone else has already joined with this email address";
            }
        } else {
            // User is joining. Check no one is already here with this email.
            if ($this_page == "userjoin" && $id_of_user_with_this_addresss) {
                $errors["email"] = "There is already a user with this email address";
            }
        }
    }
    // Check passwords.
    if ($this_page == "userjoin") {
        // Only *must* enter a password if they're joining.
        if ($details["password"] == "") {
            $errors["password"] = "Please enter {$who} password";
        } elseif (strlen($details["password"]) < 6) {
            $errors["password"] = "Please enter at least six characters";
        }
        if ($details["password2"] == "") {
            $errors["password2"] = "Please enter {$who} password again";
        }
        if ($details["password"] != "" && $details["password2"] != "" && $details["password"] != $details["password2"]) {
            $errors["password"] = ucfirst($who) . " passwords did not match. Please try again.";
        }
    } else {
        // Update details pages.
        if ($details["password"] != "" && strlen($details["password"]) < 6) {
            $errors["password"] = "Please enter at least six characters";
        }
        if ($details["password"] != $details["password2"]) {
            $errors["password"] = ucfirst($who) . " passwords did not match. Please try again.";
        }
    }
    // Check postcode (which is not a compulsory field).
    if ($details["postcode"] != "" && !validate_postcode($details["postcode"])) {
        $errors["postcode"] = "Sorry, this isn't a valid Australian postcode.";
    }
    // No checking of URL.
    if ($this_page == "otheruseredit") {
        // We're editing another user's info.
        // Could check status here...?
    }
    // Send the array of any errors back...
    return $errors;
}
開發者ID:bruno,項目名稱:openaustralia-app,代碼行數:73,代碼來源:index.php


注:本文中的USER::email_exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。