本文整理汇总了PHP中validate_email函数的典型用法代码示例。如果您正苦于以下问题:PHP validate_email函数的具体用法?PHP validate_email怎么用?PHP validate_email使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate_email函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_account_email
function check_account_email($email)
{
$result = array('error' => false, 'message' => '');
// Caution: empty email isn't counted as an error in this function.
// Check for empty value separately.
if (!strlen($email)) {
return $result;
}
if (!valid_email($email) || !validate_email($email)) {
$result['message'] .= t('Not a valid email address') . EOL;
} elseif (!allowed_email($email)) {
$result['message'] = t('Your email domain is not among those allowed on this site');
} else {
$r = q("select account_email from account where account_email = '%s' limit 1", dbesc($email));
if ($r) {
$result['message'] .= t('Your email address is already registered at this site.');
}
}
if ($result['message']) {
$result['error'] = true;
}
$arr = array('email' => $email, 'result' => $result);
call_hooks('check_account_email', $arr);
return $arr['result'];
}
示例2: validate_registration_form
/**
* Validate Registration Form
* Registration Form Validation steps:
* - check that no fields are empty.
* - check that the e-mail is valid.
* - check that the username is valid.
* - check that both repeated user passwords match.
* - check that the user password is valid.
* @param string $user_email User email provided by the user.
* @param string $user_name Username provided by the user.
* @param string $user_password Password provided by the user.
* @param string $user_password2 Repeated password provided by the user.
* @return integer The function result code (for error handling)
**/
function validate_registration_form($user_email, $user_name, $user_password, $user_password2)
{
$validation_result = SUCCESS_NO_ERROR;
if (check_empty_form([$user_email, $user_name, $user_password, $user_password2]) == TRUE) {
$validation_result = VALIDATE_REGISTER_EMPTY_FORM;
return $validation_result;
}
// check if e-mail address is valid.
$validation_result = validate_email($user_email);
if ($validation_result != SUCCESS_NO_ERROR) {
return $validation_result;
}
// check if user name is valid
$validation_result = validate_username($user_name);
if ($validation_result != SUCCESS_NO_ERROR) {
return $validation_result;
}
// check if our passwords match.
$validation_result = check_password_match($user_password, $user_password2);
if ($validation_result != SUCCESS_NO_ERROR) {
return $validation_result;
}
// check if user password is valid
$validation_result = validate_password($user_password);
if ($validation_result != SUCCESS_NO_ERROR) {
return $validation_result;
}
return $validation_result;
}
示例3: check_input
function check_input($details)
{
$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 email address is valid and unique.
if (!$details['email']) {
$errors["email"] = "Please enter your email address";
} elseif (!validate_email($details["email"])) {
// validate_email() is in includes/utilities.php
$errors["email"] = "Please enter a valid email address";
}
if ($details['pid'] && !ctype_digit($details['pid'])) {
$errors['pid'] = 'Please choose a valid person';
}
# if (!$details['keyword'])
# $errors['keyword'] = 'Please enter a search term';
if ((get_http_var('submitted') || get_http_var('only')) && !$details['pid'] && !$details['keyword']) {
$errors['keyword'] = 'Please choose a person and/or enter a keyword';
}
if (strpos($details['keyword'], '..')) {
$errors['keyword'] = 'You probably don’t want a date range as part of your criteria, as you won’t be alerted to anything new!';
}
// Send the array of any errors back...
return $errors;
}
示例4: formCheck
function formCheck($params)
{
global $_keys;
$recaptcha_valid = FALSE;
$errs = array();
if (!is_null($params["recaptcha_response_field"])) {
$resp = recaptcha_check_answer($_keys['private'], $_SERVER["REMOTE_ADDR"], $params["recaptcha_challenge_field"], $params["recaptcha_response_field"]);
if ($resp->is_valid) {
$recaptcha_valid = TRUE;
} else {
$errs['recaptcha_error'] = $resp->error;
}
}
if (!$recaptcha_valid) {
$errs['recaptcha'] = "Please complete the anti-spam test";
}
if (!$params['email']) {
$errs['email'] = "Please enter the recipient's email address";
} else {
if (!validate_email($params['email'])) {
$errs['email'] = "Please enter a valid email address for the recipient";
}
}
if (!$params['name']) {
$errs['name'] = "Please enter your name";
}
return $errs;
}
示例5: validation
function validation($usernew)
{
global $CFG;
$usernew = (object) $usernew;
$user = get_record('user', 'id', $usernew->id);
$err = array();
// validate email
if (!validate_email($usernew->email)) {
$err['email'] = get_string('invalidemail');
} else {
if ($usernew->email !== $user->email and record_exists('user', 'email', $usernew->email, 'mnethostid', $CFG->mnet_localhost_id)) {
$err['email'] = get_string('emailexists');
}
}
if ($usernew->email === $user->email and over_bounce_threshold($user)) {
$err['email'] = get_string('toomanybounces');
}
/// Next the customisable profile fields
$err += profile_validation($usernew);
if (count($err) == 0) {
return true;
} else {
return $err;
}
}
示例6: check_input
function check_input($details)
{
global $ALERT, $this_page;
$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 email address is valid and unique.
if ($details["email"] == "") {
$errors["email"] = "Please enter your email address";
} elseif (!validate_email($details["email"])) {
// validate_email() is in includes/utilities.php
$errors["email"] = "Please enter a valid email address";
}
if (!ctype_digit($details['pid']) && $details['pid'] != '') {
$errors['pid'] = 'Please choose a valid person';
}
# if (!$details['keyword'])
# $errors['keyword'] = 'Please enter a search term';
if ((get_http_var('submitted') || get_http_var('only')) && !$details['pid'] && !$details['keyword']) {
$errors['keyword'] = 'Please choose a person and/or enter a keyword';
}
// Send the array of any errors back...
return $errors;
}
示例7: login
function login($dirty_email, $dirty_password)
{
$email = escape($dirty_email);
$password = escape($dirty_password);
if (!validate_email($email)) {
echo "login-invalid-email";
return;
}
if (!validate_password($password)) {
echo "login-invalid-password";
return;
}
$account_id = account_id_from_email($email);
if ($account_id == -1) {
echo "DEBUG: email or password invalid";
return;
}
if (correct_password($account_id, $password) == false) {
echo "DEBUG: email or password invalid";
return;
}
session_regenerate_id();
fresh_logon($account_id);
$username = username_from_account_id($account_id);
setcookie('LOGGED_IN', $username, time() + 3600);
echo "login-success";
}
示例8: wikiplugin_subscribenewsletter
function wikiplugin_subscribenewsletter($data, $params)
{
global $prefs, $user;
$userlib = TikiLib::lib('user');
$tikilib = TikiLib::lib('tiki');
$smarty = TikiLib::lib('smarty');
global $nllib;
include_once 'lib/newsletters/nllib.php';
extract($params, EXTR_SKIP);
if ($prefs['feature_newsletters'] != 'y') {
return tra('Feature disabled');
}
if (empty($nlId)) {
return tra('Incorrect param');
}
$info = $nllib->get_newsletter($nlId);
if (empty($info) || $info['allowUserSub'] != 'y') {
return tra('Incorrect param');
}
if (!$userlib->user_has_perm_on_object($user, $nlId, 'newsletter', 'tiki_p_subscribe_newsletters')) {
return;
}
if ($user) {
$alls = $nllib->get_all_subscribers($nlId, false);
foreach ($alls as $all) {
if (strtolower($all['db_email']) == strtolower($user)) {
return;
}
}
}
$wpSubscribe = '';
$wpError = '';
$subscribeEmail = '';
if (isset($_REQUEST['wpSubscribe']) && $_REQUEST['wpNlId'] == $nlId) {
if (!$user && empty($_REQUEST['wpEmail'])) {
$wpError = tra('Invalid Email');
} elseif (!$user && !validate_email($_REQUEST['wpEmail'], $prefs['validateEmail'])) {
$wpError = tra('Invalid Email');
$subscribeEmail = $_REQUEST['wpEmail'];
} elseif ($user && $nllib->newsletter_subscribe($nlId, $user, 'y', 'n') || !$user && $nllib->newsletter_subscribe($nlId, $_REQUEST['wpEmail'], 'n', $info['validateAddr'])) {
$wpSubscribe = 'y';
$smarty->assign('subscribeThanks', empty($thanks) ? $data : $thanks);
} else {
$wpError = tra('Already subscribed');
}
}
$smarty->assign_by_ref('wpSubscribe', $wpSubscribe);
$smarty->assign_by_ref('wpError', $wpError);
$smarty->assign('subscribeEmail', $subscribeEmail);
$smarty->assign('subcribeMessage', empty($button) ? $data : $button);
$smarty->assign_by_ref('subscribeInfo', $info);
$res = $smarty->fetch('wiki-plugins/wikiplugin_subscribenewsletter.tpl');
if (isset($params["wikisyntax"]) && $params["wikisyntax"] == 1) {
return $res;
} else {
// if wikisyntax != 1 : no parsing of any wiki syntax
return '~np~' . $res . '~/np~';
}
}
示例9: validate
/** Tarkasta sisaankirjautumislomake
* @param $email string
* @param $password string
* @return boolean
*/
function validate($email, $password)
{
if (validate_email($email) && validate_password($password)) {
return true;
} else {
return false;
}
}
示例10: validateDetails
private function validateDetails($email, $postcode)
{
$valid = true;
if (!$email || !validate_email($email)) {
$valid = false;
}
if (!$postcode || !validate_postcode($postcode)) {
$valid = false;
}
return $valid;
}
示例11: send_token
function send_token()
{
$email = validate_email(@$_POST['email']);
if (email_overlap($email)) {
echo "email overlap";
die;
}
$mail = new PHPMailer();
//实例化
$mail->IsSMTP();
// 启用SMTP
$mail->Host = $GLOBALS['smtp_server'];
//SMTP服务器 以163邮箱为例子
$mail->Port = $GLOBALS['smtp_server_port'];
//邮件发送端口
$mail->SMTPAuth = true;
//启用SMTP认证
$mail->CharSet = "UTF-8";
//字符集
$mail->Encoding = "base64";
//编码方式
$mail->Username = $GLOBALS['smtp_user_mail'];
//你的邮箱
$mail->Password = $GLOBALS['smtp_user_pass'];
//你的密码
$mail->Subject = "NutLab SS Token";
//邮件标题
$mail->From = $GLOBALS['smtp_user_mail'];
//发件人地址(也就是你的邮箱)
$mail->FromName = "NutLab";
//发件人姓名
$address = $email;
//收件人email
$mail->AddAddress($address, "Dear");
//添加收件人(地址,昵称)
$mail->IsHTML(true);
//支持html格式内容
$token = generate_token();
$mail->Body = "感谢您在我站注册了新帐号。<br/><br/>你的验证码为" . $token;
//邮件主体内容
if (!$mail->Send()) {
echo "token sending fail:" . $mail->ErrorInfo;
echo "token sending fail";
} else {
echo "token sending success";
}
$count = count($GLOBALS['DB']->query("SELECT * FROM user WHERE email=? ", array($email)));
if ($count > 0) {
$result = $GLOBALS['DB']->query("UPDATE user SET token=? WHERE email=?", array($token, $email));
} else {
$result = $GLOBALS['DB']->query("INSERT INTO user (email,pass,passwd,u,d,transfer_enable,port,enable,activated,token) VALUES (?,'','','0','0','0',?,'0','0',?)", array($email, generate_port(), $token));
}
}
示例12: success
function success()
{
global $systemArr;
global $messageArr;
$SystemEmailAccount = $systemArr;
$email = $systemArr["email"];
$error = "";
$returnMessage = "";
$success = true;
$messageheading = $messageArr["messageHead"];
$messageSubject = $messageArr["messageSubject"];
$responseHeading = $messageArr["responseHead"];
$responseMessage = $messageArr["responseMessage"];
$responseSig = $messageArr["responseSig"];
$responseSubject = $messageArr["responseSubject"];
$responseEnd = $messageArr["responseEnd"];
if (isset($_POST["email"])) {
//$emailClient = mysql_real_escape_string($_POST["email"]);
$emailClient = $_POST["email"];
if (validate_email($emailClient)) {
$name = $_POST["name"];
//$emailClient = $_POST["email"];
$title = $_POST["title"];
$message = $_POST["message"];
$messageContent = " <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n </head>\n <body style='font-family: calibri, sans-serif; font-size: 16px;'>\n \n <h1 style='padding: 10px; background-color: #1f1f1f; color: #ffffff; font-size: 28px;'>Hi there! You've received {$messageheading} from your website :)</h1>\n \n <table style='border-spacing: 0px; border: 1px solid #ccc; border-bottom: none;'>\n <tr>\n <td width='20%' style='padding: 5px; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc;'>Enquirer's Name</td>\n <td width='80%' style='padding: 5px; border-bottom: 1px solid #ccc;'>{$name}</td>\n </tr>\n <tr>\n <td style='padding: 5px; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc;'>Enquirer's Email Address</td>\n <td style='padding: 5px; border-bottom: 1px solid #ccc;'>{$emailClient}</td>\n </tr>\n <tr>\n <td style='padding: 5px; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc;'>Message Title</td>\n <td style='padding: 5px; border-bottom: 1px solid #ccc;'>{$title}</td>\n </tr>\n <tr>\n <td style='padding: 5px; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc;'>Enquirer's Message</td>\n <td style='padding: 5px; border-bottom: 1px solid #ccc;'>{$message}</td>\n </tr>\n </table>\n \n <h2 style='padding: 10px; background-color: #1f1f1f; color: #ffffff; font-size: 28px;'>Enjoy your day!</h2>\n \n <p style='padding: 10px; background-color: #eee; color: #777; font-size: 12px;'>Brought to you by <b>Epicdev</b><sup>tm</sup>. Please do not hesitate to contact us for any general or support related queries at info@epicdev.co.za</p>\n \n </body>\n </html> ";
//////////////////////////////////// HTML CODE FOR CLIENT ENQUIRY EMAIL ////////////////////////////////////
$status = sendMail(array($email), $SystemEmailAccount, $messageSubject, $messageContent, null);
if ($status["status"] == true) {
$returnMessage = "Message Sent";
$messageRespond = " <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n </head>\n <body style='font-family: calibri, sans-serif; font-size: 16px;'>\n \n <h1 style='padding: 10px; background-color: #00CB16; color: #ffffff; font-size: 28px;'>{$responseHeading}</h1>\n \n <table style='border-spacing: 0px; border: 1px solid #ccc; border-bottom: none;'>\n <tr>\n <td width='100%' style='padding: 5px; border-bottom: 1px solid #ccc;'>{$responseMessage}</td>\n </tr>\n </table>\n \n <p style='padding: 10px 0 0 0; color: #00CB16; font-size: 24px; font-weight: bold; margin: 0'>{$responseEnd}</p>\n <p style='padding: 0; color: #00CB16; font-size: 18px; margin: 0 0 10px 0'>{$responseSig}</p>\n \n <p style='padding: 10px; background-color: #eee; color: #777; font-size: 11px;'>Brought to you by <b>Epicdev</b><sup>tm</sup> - www.epicdev.co.za. Please do not hesitate to contact us for any general or support related queries at info@epicdev.co.za</p>\n \n </body>\n </html> ";
//////////////////////////////////// HTML CODE FOR CLIENT RESPONSE EMAIL ////////////////////////////////////
if (validate_email($emailClient)) {
$status2 = sendMail(array($emailClient), $SystemEmailAccount, $responseSubject, $messageRespond, null);
if ($status2["status"] != true) {
}
}
} else {
$returnMessage = "Failed to send message";
$success = false;
}
} else {
$returnMessage = "Invalid Email Address";
$success = false;
}
}
header('Content-type: application/json');
if ($success == true) {
$success = 1;
} else {
$success = 0;
}
echo "{\"status\":" . $success . ", \"message\":\"" . $returnMessage . "\"}";
}
示例13: config_form
/**
* Creates necessary fields in the messaging config form.
* @param object $mform preferences form class
*/
function config_form($preferences)
{
global $USER, $OUTPUT;
$inputattributes = array('size' => '30', 'name' => 'email_email', 'value' => $preferences->email_email);
$string = get_string('email', 'message_email') . ': ' . html_writer::empty_tag('input', $inputattributes);
if (empty($preferences->email_email) && !empty($preferences->userdefaultemail)) {
$string .= ' (' . get_string('default') . ': ' . s($preferences->userdefaultemail) . ')';
}
if (!empty($preferences->email_email) && !validate_email($preferences->email_email)) {
$string .= $OUTPUT->container(get_string('invalidemail'), 'error');
}
return $string;
}
示例14: account_register_new
function account_register_new($unix_name, $realname, $password1, $password2, $email, $language, $timezone, $mail_site, $mail_va, $language_id, $timezone)
{
global $feedback;
if (db_numrows(db_query("SELECT user_id FROM users WHERE user_name LIKE '{$unix_name}'")) > 0) {
$feedback .= "That username already exists.";
return false;
}
// Check that username is not identical with an existing unix groupname (groups) helix 22.06.2001
if (db_numrows(db_query("SELECT unix_group_name FROM groups WHERE unix_group_name LIKE '{$unix_name}'")) > 0) {
$feedback .= "That username is identical with the unixname of an existing group.";
return false;
}
// End of change helix 22.06.2001
if (!$unix_name) {
$feedback .= "You must supply a username.";
return false;
}
if (!$password1) {
$feedback .= "You must supply a password.";
return false;
}
if ($password1 != $password2) {
$feedback .= "Passwords do not match.";
return false;
}
if (!account_pwvalid($password1)) {
$feedback .= ' Password must be at least 6 characters. ';
return false;
}
if (!account_namevalid($unix_name)) {
$feedback .= ' Invalid Unix Name ';
return false;
}
if (!validate_email($email)) {
$feedback .= ' Invalid Email Address ';
return false;
}
// if we got this far, it must be good
$confirm_hash = substr(md5($session_hash . $HTTP_POST_VARS['form_pw'] . time()), 0, 16);
$result = db_query("INSERT INTO users (user_name,user_pw,unix_pw,realname,email,add_date," . "status,confirm_hash,mail_siteupdates,mail_va,language,timezone) " . "VALUES ('{$unix_name}'," . "'" . md5($password1) . "'," . "'" . account_genunixpw($password1) . "'," . "'" . "{$realname}'," . "'{$email}'," . "'" . time() . "'," . "'P'," . "'{$confirm_hash}'," . "'" . ($mail_site ? "1" : "0") . "'," . "'" . ($mail_va ? "1" : "0") . "'," . "'{$language_id}'," . "'{$timezone}')");
$user_id = db_insertid($result, 'users', 'user_id');
if (!$result || !$user_id) {
$feedback .= ' Insert Failed ' . db_error();
return false;
} else {
// send mail
$message = "Thank you for registering on the " . $GLOBALS['sys_default_name'] . " web site. In order\n" . "to complete your registration, visit the following url: \n\n" . "https://" . $GLOBALS['HTTP_HOST'] . "/account/verify.php?confirm_hash={$confirm_hash}\n\n" . "Enjoy the site.\n\n" . " -- the " . $GLOBALS['sys_default_name'] . " staff\n";
mail($email, $GLOBALS['sys_default_name'] . " Account Registration", $message, "From: noreply@" . $GLOBALS['sys_default_domain']);
return $user_id;
}
}
示例15: validate_input
function validate_input()
{
global $errors;
$email = stripslashes(trim($_POST['email']));
// Did the user enter anything?
if ($email == '') {
$errors['email'] = '<b><font color="red">***Email' . ' address?***</font><b>';
} else {
$ok = validate_email($email);
if (!$ok) {
$errors['email'] = '<b><font color="red">***Invalid' . ' email address***</font></b>';
}
}
}