A solution to validate email was found. It is a complicated process but works perfectly !!!
1. Add following lines to membership_signup.php (in root folder)
just below:
Code: Select all
<div class="form-group">
<label for="email" class="control-label"><?php echo $Translation['email']; ?></label>
<input class="form-control" type="text" required="" placeholder="<?php echo $Translation['email']; ?>" id="email" name="email">
Put below code block:
Code: Select all
<span id="emailAvailable" class="help-block hidden pull-left"><i class="glyphicon glyphicon-ok"></i> <?php echo str_ireplace(array("'", '"', '<memberid>'), '', "Email available for registration"); ?></span>
<span id="emailNotAvailable" class="help-block hidden pull-left"><i class="glyphicon glyphicon-remove"></i> <?php echo str_ireplace(array("'", '"', '<memberid>'), '', "Email is invalid or already registered !!!. Try resetting the password or contact admin"); ?></span>
<div class="clearfix"></div>
just below:
Code: Select all
$j('#confirmPassword').on('keyup blur', function() {
if($j('#confirmPassword').val() != $j('#password').val() || !$j('#confirmPassword').val().length) {
$j('#confirmPassword').parents('.form-group').removeClass('has-success').addClass('has-error');
} else {
$j('#confirmPassword').parents('.form-group').removeClass('has-error').addClass('has-success');
}
});
Put below code block:
Code: Select all
/* email availability check */
$j('#emailAvailable, #emailNotAvailable').click(function() { $j('#email').focus(); });
$j('#email').on('keyup blur', checkEmail);
just below:
Code: Select all
function reset_username_status(status) {
$j('#usernameNotAvailable, #usernameAvailable')
.addClass('hidden')
.parents('.form-group')
.removeClass('has-error has-success');
if(status == undefined) return;
if(status == 'success') {
$j('#usernameAvailable')
.removeClass('hidden')
.parents('.form-group')
.addClass('has-success');
}
if(status == 'error') {
$j('#usernameNotAvailable')
.removeClass('hidden')
.parents('.form-group')
.addClass('has-error');
}
}
Put below code block:
Code: Select all
var uaro2; // email availability request object
function checkEmail() {
// abort previous request, if any
if(uaro2 != undefined) uaro2.abort();
reset_email_status();
uaro2 = $j.ajax({
url: 'checkEmail.php',
type: 'GET',
data: { 'email': $j('#email').val() },
success: function(resp) {
var ua=resp;
if(ua.match(/\<!-- AVAILABLE --\>/)) {
reset_email_status('success');
} else {
reset_email_status('error');
}
}
});
}
function reset_email_status(status) {
$j('#emailNotAvailable, #emailAvailable')
.addClass('hidden')
.parents('.form-group')
.removeClass('has-error has-success');
if(status == undefined) return;
if(status == 'success') {
$j('#emailAvailable')
.removeClass('hidden')
.parents('.form-group')
.addClass('has-success');
}
if(status == 'error') {
$j('#emailNotAvailable')
.removeClass('hidden')
.parents('.form-group')
.addClass('has-error');
}
}
Just below:
Code: Select all
if(!validateEmail(email)) {
modal_window({ message: '<div class="alert alert-danger"><?php echo html_attr($Translation['email invalid']); ?></div>', title: "<?php echo html_attr($Translation['error:']); ?>", close: function() { $j('#email').focus(); } });
return false;
}
Put following code block:
Code: Select all
/* email exists? */
if(!$j('#email').parents('.form-group').hasClass('has-success')) {
modal_window({ message: '<div class="alert alert-danger"><?php echo html_attr("This email address is already registered !!! Please try resetting the password or contact admin" ); ?></div>', title: "<?php echo html_attr($Translation['error:']); ?>", close: function() { $j('#email').focus(); } });
return false;
}
2. Create a file named checkEmail.php in the root folder and put the following code in it
Code: Select all
<?php
$currDir = dirname(__FILE__);
include_once("{$currDir}/lib.php");
include_once("{$currDir}/header.php");
$current_user = isset($_REQUEST['currentUser']) ? $_REQUEST['currentUser'] : false;
$email = is_allowed_email($_REQUEST['email'], $current_user);
?>
<style>
nav, .hidden-print{ display: none; }
</style>
<div style="height: 1em;"></div>
<?php if($email) { ?>
<div class="alert alert-success">
<i class="glyphicon glyphicon-ok"></i>
<?php echo str_replace('<email>', "<b>{$username}</b>", "Email already registered !!!"); ?>
<!-- AVAILABLE -->
</div>
<?php } else { ?>
<div class="alert alert-danger">
<i class="glyphicon glyphicon-warning-sign"></i>
<?php echo str_replace('<email>', '<b>' . html_attr($_REQUEST['email']) . '</b>', "Email is invalid !!!"); ?>
<!-- NOT AVAILABLE -->
</div>
<?php } ?>
<div class="text-center">
<input type="button" value="Close" onClick="window.close();" autofocus class="btn btn-default btn-lg">
</div>
<?php include_once("{$currDir}/footer.php"); ?>
3. Goto admin/incFunctions.php and look for
Code: Select all
########################################################################
function is_allowed_username($username, $exception = false) {
$username = trim(strtolower($username));
if(!preg_match('/^[a-z0-9][a-z0-9 _.@]{3,100}$/', $username) || preg_match('/(@@| |\.\.|___)/', $username)) return false;
if($username == $exception) return $username;
if(sqlValue("select count(1) from membership_users where lcase(memberID)='{$username}'")) return false;
return $username;
}
########################################################################
Add the following code block just below the above code
Code: Select all
function is_allowed_email($email, $exception = false) {
$email = trim(strtolower($email));
if(sqlValue("select count(1) from membership_users where lcase(email)='{$email}'")) return false;
return $email;
}
If all these changes are successfully made your registration form will look for the existing email addresses and alert the user if he is using one of the already registered email addresses like the system check for the same username.
Hope our experts suggest a simple method or Ahamed add this in the next release......
Open for discussion....