How can I add 'confirm the email address entered'?

How can I add a confirmation that someone completing this Registration is entering the correct email? essentially checking it for for a match (before submitting)?
Thanks fo any help

<?php
if (IS_LOGGED == true || $pt->config->user_registration != 'on') {
    header("Location: " . PT_Link(''));
    exit();
}

//$color1      = '2ec0bc';
//$color2      = '8ef9f6';

$color1      = '0f4240';
$color2      = '25eae4';
$errors      = array();
$erros_final = '';
$username    = '';
$email       = '';
$success     = '';
$recaptcha   = '<div class="g-recaptcha" data-sitekey="' . $pt->config->recaptcha_key . '"></div>';
$pt->custom_fields = $db->where('registration_page','1')->get(T_FIELDS);
$field_data        = array();
if ($pt->config->recaptcha != 'on') {
    $recaptcha = '';
}
if (!empty($_POST)) {
    if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email']) || empty($_POST['c_password']) || empty($_POST['gender'])) {
        $errors[] = $lang->please_check_details;
    } else {
        $username        = PT_Secure($_POST['username']);
        $password        = PT_Secure($_POST['password']);
        $c_password      = PT_Secure($_POST['c_password']);
        $password_hashed = sha1($password);
        $email           = PT_Secure($_POST['email']);
        $gender          = PT_Secure($_POST['gender']);
        if ($gender != 'female' && $gender != 'male') {
            $errors[] = $lang->gender_is_invalid;
        }
        if (PT_UsernameExists($_POST['username'])) {
            $errors[] = $lang->username_is_taken;
        }
        if (strlen($_POST['username']) < 4 || strlen($_POST['username']) > 32) {
            $errors[] = $lang->username_characters_length;
        }
        if (!preg_match('/^[\w]+$/', $_POST['username'])) {
            $errors[] = $lang->username_invalid_characters;
        }
        if (PT_UserEmailExists($_POST['email'])) {
            $errors[] = $lang->email_exists;
        }
        if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
            $errors[] = $lang->email_invalid_characters;
        }
        if ($password != $c_password) {
            $errors[] = $lang->password_not_match;
        }
        if (strlen($password) < 4) {
            $errors[] = $lang->password_is_short;
        }
        if ($pt->config->recaptcha == 'on') {
            if (!isset($_POST['g-recaptcha-response']) || empty($_POST['g-recaptcha-response'])) {
                $errors[] = $lang->reCaptcha_error;
            }
        }

        if (empty($_POST['terms'])) {
            $errors[] = $lang->terms_accept;
        } elseif ($_POST['terms'] != 'on') {
            $errors[] = $lang->terms_accept;
        }


        if (!empty($pt->custom_fields) && count($pt->custom_fields) > 0) {
            foreach ($pt->custom_fields as $field) {
                $field_id   = $field->id;
                $field->fid = "fid_$field_id";

                if (!empty($_POST[$field->fid])) {
                    $name = $field->fid;
                    if (!empty($_POST[$name])) {
                        $field_data[] = array(
                            $name => $_POST[$name]
                        );
                    }
                }
            }
        }


        $active = ($pt->config->validation == 'on') ? 0 : 1;
        if (empty($errors)) {
            $email_code = sha1(time() + rand(111,999));
            $insert_data = array(
                'username' => $username,
                'password' => $password_hashed,
                'email' => $email,
                'ip_address' => get_ip_address(),
                'gender' => $gender,
                'active' => $active,
                'email_code' => $email_code,
                'last_active' => time(),
                'registered' => date('Y') . '/' . intval(date('m'))
            );
            $insert_data['language'] = $pt->config->language;
            if (!empty($_SESSION['lang'])) {
                if (in_array($_SESSION['lang'], $langs)) {
                    $insert_data['language'] = $_SESSION['lang'];
                }
            }
            $user_id             = $db->insert(T_USERS, $insert_data);
            if (!empty($user_id)) {
                if (!empty($field_data)) {
                    PT_UpdateUserCustomData($user_id,$field_data,false);
                }


                if ($pt->config->validation == 'on') {
                     $link = $email_code . '/' . $email;
                     $data['EMAIL_CODE'] = $link;
                     $data['USERNAME']   = $username;
                     $send_email_data = array(
                        'from_email' => $pt->config->email,
                        'from_name' => $pt->config->name,
                        'to_email' => $email,
                        'to_name' => $username,
                        'subject' => 'Confirm your account',
                        'charSet' => 'UTF-8',
                        'message_body' => PT_LoadPage('emails/confirm-account', $data),
                        'is_html' => true
                    );
                    $send_message = PT_SendMessage($send_email_data);
                    $success = $success_icon . $lang->successfully_joined_desc;
                }

                else {
                    $session_id          = sha1(rand(11111, 99999)) . time() . md5(microtime());
                    $insert_data         = array(
                        'user_id' => $user_id,
                        'session_id' => $session_id,
                        'time' => time()
                    );
                    $insert              = $db->insert(T_SESSIONS, $insert_data);
                    $_SESSION['user_id'] = $session_id;
                    setcookie("user_id", $session_id, time() + (10 * 365 * 24 * 60 * 60), "/");
                    $pt->loggedin = true;
                    header("Location: $site_url");
                    exit();
                }
            }
        }
    }
}
$pt->page          = 'login';
$pt->title         = $lang->register . ' | ' . $pt->config->title;
$pt->description   = $pt->config->description;
$pt->keyword       = $pt->config->keyword;
$custom_fields     = "";
if (!empty($errors)) {
    foreach ($errors as $key => $error) {
        $erros_final .= $error_icon . $error . "<br>";
    }
}
if (!empty($pt->custom_fields)) {
    foreach ($pt->custom_fields as $field) {
        $field_id       = $field->id;
        $fid            = "fid_$field_id";
        $pt->filed      = $field;
        $custom_fields .= PT_LoadPage('auth/register/custom-fields',array(
            'NAME'      => $field->name,
            'FID'       => $fid
        ));
    }
}

$pt->content     = PT_LoadPage('auth/register/content', array(
    'COLOR1' => $color1,
    'COLOR2' => $color2,
    'ERRORS' => $erros_final,
    'USERNAME' => $username,
    'EMAIL' => $email,
    'SUCCESS' => $success,
    'RECAPTCHA' => $recaptcha,
    'CUSTOM_FIELDS' => $custom_fields
));

So, you are saying you are going to verify e-mail submissions by a secondary form that only verifies the e-mail address.

Seemingly, the logic to this would be very simple:

if ($email == $confirmedemail) {
  /* execute next step of signup */
}
else {
 /* send back failure status to JS */
}

You can have the secondary form collect the one field in question- the e-mail. Store it in $confirmedemail.

Check if the e-mail addresses are the same as this is the first scrub of the data validation . Maybe you can call the short script emailchecker.php or something. If the e-mails match, then create your objects for executing your code above.

Where is the HTML and/or JS attached to this?

Thanks for your help.Here is the html:

l<div class="container login-page">
    <div class="login-form">
        <h4>{{LANG lets_get_started}}</h4>
    	<form action="{{LINK register}}" method="POST">
    	    <div class="errors form-group">{{ERRORS}}</div>
    	     <div class="errors success form-group">{{SUCCESS}}</div>
			<div class="form-group">
				<input type="text" name="username" id="username" placeholder="{{LANG username}}" required value="{{USERNAME}}">
			</div>
			<div class="form-group">
				<input type="text" name="email" id="email" placeholder="{{LANG email_address}}" required value="{{EMAIL}}">
			</div>
			<div class="form-group">
				<input type="password" name="password" id="password" placeholder="{{LANG password}}" required>
			</div>
			<div class="form-group">
				<input type="password" name="c_password"  id="c_password" placeholder="{{LANG confirm_password}}" required>
			</div>
			<div class="form-group">
				<select name="gender" id="gender" required>
					<option value="male">{{LANG male}}</option>
					<option value="female">{{LANG female}}</option>
				</select>
			</div>
			{{CUSTOM_FIELDS}}

			 <div class="terms" style="color: #fff">
		      <label for="accept_terms" style="font-size: 12px; cursor: pointer;"><input type="checkbox" style="float: left; width: auto; display: inline-block; margin-right: 5px; margin-top: 2px;" name="accept_terms" id="accept_terms"> 
		       {{LANG terms_agreement}}
		       <a style="color: #fff; text-decoration: underline;" href="{{LINK terms/terms}}">{{LANG terms_of_use}}</a> & <a href="{{LINK terms/privacy-policy}}" style="color: #fff; text-decoration: underline;">{{LANG privacy_policy}}</a>
		       </label>
		       <div class="clear"></div>
		     </div>

			<div class="recaptcha">{{RECAPTCHA}}</div>
			<div class="form-group">
				<input type="submit" class="button" value ="{{LANG sign_up}}">
			</div>
			<div class="new-here text-center">
				{{LANG already_have_account}} <a class="dec" href="{{LINK login}}">{{LANG login_}}</a>
			</div>
			<input type="hidden" id="checked" value="off" name="terms">
		</form>
    </div>    
</div>
<ul class="bg-bubbles">
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
</ul>
<script>
$(function() {
	$("#accept_terms").change(function() {
	    if(this.checked) {
	        $('#checked').val('on');
	    } else {
	    	$('#checked').val('off');
	    }
	});
	$('.button').on('click', function () {
		if ($('#username').val() && $('#password').val() && $('#email').val() && $('#gender').val() && $('#c_password').val()) {
			$(this).val("{{LANG please_wait}}");
		}
	});
});
</script>
<style>
.bg-bubbles {
  background: -webkit-linear-gradient(top left, #{{COLOR1}} 0%, #{{COLOR2}} 100%);
  background: linear-gradient(to bottom right, #{{COLOR1}} 0%, #{{COLOR2}} 100%);
}
.login-page {
	margin-top: 150px;
}
.login-form input[type=submit] {
	color: #{{COLOR1}} !important;
}
::-webkit-input-placeholder { /* WebKit, Blink, Edge */
    color:    #fff;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
   color:    #fff;
   opacity:  1;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
   color:    #fff;
   opacity:  1;
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
   color:    #fff;
}
::-ms-input-placeholder { /* Microsoft Edge */
   color:    #fff;
}
</style>

In my searching I also found this:

$emailCheck=strtolower($emai1l);
$emailConfirm=strtolower($email2);

if ($emailCheck==$emailConfirm) {

// send the form 

} else {

// return to the form
}

is that similar to your example?
If I didn’t explain myself better, I’m just looking to have both email field entries to match.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.