Better email error checking, fixes #2046

git-svn-id: https://develop.svn.wordpress.org/trunk@3507 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg 2006-02-09 08:11:26 +00:00
parent 0628227ea0
commit b17e0b1ef3
2 changed files with 14 additions and 8 deletions

View File

@ -10,6 +10,14 @@ function username_exists( $username ) {
return null;
}
function email_exists( $email ) {
global $wpdb;
$email = addslashes( $email );
$email_exists = $wpdb->get_row("SELECT user_email FROM $wpdb->users WHERE user_email = '$email'");
if ( $email_exists)
return true;
}
function validate_username( $username ) {
$name = sanitize_user($username, true);
$valid = true;

View File

@ -33,10 +33,8 @@ case 'register':
if ( username_exists( $user_login ) )
$errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
/* checking the email isn't already used by another user */
$email_exists = $wpdb->get_row("SELECT user_email FROM $wpdb->users WHERE user_email = '$user_email'");
if ( $email_exists)
die (__('<strong>ERROR</strong>: This email address is already registered, please supply another.'));
if ( email_exists( $user_email ) )
$errors['user_email'] = __('<strong>ERROR</strong>: This email is already registered, please choose another one.');
if ( 0 == count($errors) ) {
$password = substr( md5( uniqid( microtime() ) ), 0, 7);
@ -49,7 +47,7 @@ case 'register':
}
if ( 0 == count($errors) ) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@ -101,11 +99,11 @@ default:
<h2><?php _e('Register for this blog') ?></h2>
<?php if ( isset($errors) ) : ?>
<div class="error">
<ul>
<p>
<?php
foreach($errors as $error) echo "<li>$error</li>";
foreach($errors as $error) echo "$error<br />";
?>
</ul>
</p>
</div>
<?php endif; ?>
<form method="post" action="wp-register.php" id="registerform">