Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Ride on August 25, 2004, 01:14:37 PM

Title: User must enter email twice during registration
Post by: Ride on August 25, 2004, 01:14:37 PM
I get a lot of bounced emails with people registering with things like "[email protected]" or "[email protected]."   Simple typos.  It'd be nice to make them enter their email twice and verify it's the same.  This would cut down on registration mistakes.  I did a search for this but didn't find anything.
Title: Re: User must enter email twice during registration
Post by: Oldiesmann on August 25, 2004, 05:05:53 PM
Easy enough to do...

In Themes/default/Register.template.php

Find
// Are they allowed to hide their email?
if ($context['allow_hide_email'])
echo '
<input type="checkbox" name="hideEmail" class="check" id="hideEmail" /> <label for="hideEmail">', $txt[721], '</label>';

echo '
</td>
</tr><tr>


Add after
<td width="40%">
<b>Verify ', $txt[69], ':</b>
<div class="smalltext">This is just to make sure you didn\'t mis-type your email address...</div>
</td>
<td>
<input type="text" name="email2" size="30" />
</td>
</tr><tr>


In Sources/Register.php

Find:
if (empty($_POST['email']) || preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]+@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['email']) == 0)
fatal_error(sprintf($txt[500], $_POST['user']), false);


Add after:


if (empty($_POST['email2']) || $_POST['email2'] != $_POST['email'])
fatal_lang_error('Email addresses aren\'t the same.', false);


That should do it.
Title: Re: User must enter email twice during registration
Post by: Ride on August 25, 2004, 08:17:06 PM
Thank you very much!
Title: Re: User must enter email twice during registration
Post by: [Unknown] on August 25, 2004, 11:43:55 PM
Also note that people can go back and change their email address....

-[Unknown]
Title: Re: User must enter email twice during registration
Post by: williammc on August 26, 2004, 12:16:19 AM
A nice little addition there, been added on my forum, thanks Oldiesmann.
Title: Re: User must enter email twice during registration
Post by: madfiddler on August 27, 2004, 08:57:23 PM
Thanks. I'm getting a load of members who apparently can't type their email address correctly...
Title: Re: User must enter email twice during registration
Post by: Tristan Perry on August 30, 2004, 10:01:48 AM
Hi all,
I've tried to add this but when I test it out I get the following error at the top of the page:

QuoteNotice: Undefined index: Email addresses aren't the same. in /home/tauonli/public_html/forums/Sources/Errors.php on line 233

And the 'An Error Has Occurred!' box has nothing in it...any help?
Title: Re: User must enter email twice during registration
Post by: [Unknown] on August 30, 2004, 02:51:45 PM
Find:
fatal_lang_error('Email addresses aren\'t the same.', false);

Replace:
fatal_error('Email addresses aren\'t the same.', false);

-[Unknown]
Title: Re: User must enter email twice during registration
Post by: Tristan Perry on August 31, 2004, 04:59:25 AM
Quote from: [Unknown] on August 30, 2004, 02:51:45 PM
Find:
fatal_lang_error('Email addresses aren\'t the same.', false);

Replace:
fatal_error('Email addresses aren\'t the same.', false);

-[Unknown]
Thanks  :)
Title: Re: User must enter email twice during registration
Post by: Elmacik on September 02, 2005, 03:14:32 PM
is this included in 1.1 beta 3 ?
if not, how can we do it?
Title: Re: User must enter email twice during registration
Post by: Anakin_holland on September 02, 2005, 04:01:38 PM
Great solution Oldiesmann, nice trouble-shooting [Unknown] ! 8)

Implemented it right away!

@elmacik, You can check if it's inlcuded, by taking a look at the registration-procedure at this very board? If it isn't you could take a look at the files an see if they look the same as what Oldiesmann posted? If it is, it probably works the same as well?

Greetz!

Anakin
Title: Re: User must enter email twice during registration
Post by: 1MileCrash on September 02, 2005, 04:04:55 PM
Quote from: [Unknown] on August 25, 2004, 11:43:55 PM
Also note that people can go back and change their email address....

-[Unknown]

even if email activation is required, and theyre not activated?
Title: Re: User must enter email twice during registration
Post by: Elmacik on September 02, 2005, 04:16:58 PM
didnt work for 1.1 beta 3
Title: Re: User must enter email twice during registration
Post by: modtang on September 11, 2005, 04:03:25 AM
This is simple to install and a good idea. Works fine on 1.0.5. :)
Title: Re: User must enter email twice during registration
Post by: Wounded Knee on October 15, 2005, 04:53:40 PM
work in 1.1 RC1?
Title: Re: User must enter email twice during registration
Post by: houston on November 17, 2005, 10:16:35 PM
Can't find

   if (empty($_POST['email']) || preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]+@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['email']) == 0)
fatal_error(sprintf($txt[500], $_POST['user']), false);


In Sources/Register.php of 1.1 rc1
Title: Re: User must enter email twice during registration
Post by: SleePy on November 27, 2005, 01:56:42 AM
Quote from: houston on November 17, 2005, 10:16:35 PM
Can't find

   if (empty($_POST['email']) || preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]+@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['email']) == 0)
fatal_error(sprintf($txt[500], $_POST['user']), false);


In Sources/Register.php of 1.1 rc1

neither could i. but i went about it a different way


In Themes/default/Register.template.php

Find:
// Are they allowed to hide their email?
if ($context['allow_hide_email'])
echo '
<input type="checkbox" name="hideEmail" class="check" id="hideEmail" /> <label for="hideEmail">', $txt[721], '</label>';

echo '
</td>
</tr><tr>


Add After:
<td width="40%">
<b>Verify ', $txt[69], ':</b>
<div class="smalltext">This is just to make sure you didn\'t mis-type your email address...</div>
</td>
<td>
<input type="text" name="email2" size="30" tabindex="', $context['tabindex']++, '" />
</td>
</tr><tr>

Note: I added the tabindex so when people are registering and just tabing though the fields it doesnt get missed.
Find:

if (document.forms.creator.passwrd1.value != document.forms.creator.passwrd2.value)
{
alert("', $txt['register_passwords_differ_js'], '");
return false;
}


Replace With:

if (document.forms.creator.passwrd1.value != document.forms.creator.passwrd2.value && document.forms.creator.email.value != document.forms.creator.email2.value)
{
alert("The E-Mail Address you have entered to not Match. The Passwords You have Entered do not Match. Please Check them again to make sure they are correct.");
return false;
}

if (document.forms.creator.passwrd1.value != document.forms.creator.passwrd2.value)
{
alert("', $txt['register_passwords_differ_js'], '");
return false;
}


if (document.forms.creator.email.value != document.forms.creator.email2.value)
{
alert("The E-Mail Address you have Entered are NOT the same. Please Check them to make sure they are correct");
return false;
}';


that is how i was able to get it working
i do not know were $txt['register_passwords_differ_js'] is. i thought it would be in errors.english.php but it is not. if you know were it is. please tell me and you can add your alert there using
         alert("', $txt['register_emails_differ_js'], '");
and
         alert("', $txt['register_passwords_emails_differ_js'], '");

Title: Re: User must enter email twice during registration
Post by: rokit on March 02, 2006, 04:44:55 PM
Thanks so much for this.  I get the same problem that you guys have encountered.  Member send me emails or post threads saying they can't log in because they never receieved an activation email. =_=
Title: Re: User must enter email twice during registration
Post by: Ganghiss on April 17, 2006, 10:39:17 AM
Quotei do not know were $txt['register_passwords_differ_js'] is. i thought it would be in errors.english.php but it is not. if you know were it is. please tell me and you can add your alert there using
         alert("', $txt['register_emails_differ_js'], '");
and
         alert("', $txt['register_passwords_emails_differ_js'], '");

SleePy, you can find $txt['register_passwords_differ_js'] in Login.english.php located in Themes/default/languages/.
Title: Re: User must enter email twice during registration
Post by: Ganghiss on April 18, 2006, 05:25:40 PM
Although it seems just adding the alerts creates a parsing error. I may have tossed them into login.english.php wrong.
Title: Re: User must enter email twice during registration
Post by: xjessie007 on October 12, 2008, 01:32:12 PM
You are getting parse errors because there is a little omission in Sleepy's code. The code as he posted it here perhaps may have worked in his version and config, but I am getting parse error in 1.1.6 too. So, here is how to fix it.

a) There needs to be a semicolon after }.
b) Watch out for the tick at the end of the code. The tick at the end of the code is just the closing tick for the echo statement.

   echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
   function verifyAgree()
   {
      if (document.forms.creator.passwrd1.value != document.forms.creator.passwrd2.value)
      {
         alert("', $txt['register_passwords_differ_js'], '");
         return false;
      };

      if (document.forms.creator.passwrd1.value != document.forms.creator.passwrd2.value && document.forms.creator.email.value != document.forms.creator.email2.value)
      {
         alert("The e-mail addresses you have entered to NOT match. The passwords You have entered do not match. Please check them again to make sure they are correct.");
         return false;
      };

      if (document.forms.creator.email.value != document.forms.creator.email2.value)
      {
         alert("The e-mail address you have entered are NOT the same. Please check them to make sure they are correct");
         return false;
      }';


In case you are getting parse errors when implementing this functionality, check the red code in your code. SleePy's code is missing the semicolons.

By the way, there is a module called EmailValidator. This mod nicely comliments this functionality. Check it out here: http://custom.simplemachines.org/mods/index.php?mod=1353

-------------
www.maxi-pedia.com - Maxi-Pedia: Your resource for finance & IT!
www.finance-management.cz - Central European Center for Finance and Management
Title: Re: User must enter email twice during registration
Post by: kbarg on November 02, 2008, 12:51:08 AM
This is nice, thanks
Title: Do anyone know how to force users to must enter birthdate and location during re
Post by: kirderf on November 02, 2008, 01:45:53 PM

Do anyone know how to force users to must enter birthdate and location during registration ?
Title: Re: User must enter email twice during registration
Post by: Oldiesmann on December 02, 2008, 08:37:07 PM
Do you still need help with this kirderf?
Title: Re: User must enter email twice during registration
Post by: unformatted_ on October 21, 2009, 10:11:34 AM
How can I do this to SMF 1.1.9?

Thanks
Title: Re: User must enter email twice during registration
Post by: raghhav on December 01, 2009, 10:37:38 AM
this is not happening in 1.1.10, kindly help
Title: Re: User must enter email twice during registration
Post by: Oldiesmann on February 16, 2010, 10:41:00 PM
Do you still need help with this raghhav?
Title: Re: User must enter email twice during registration
Post by: raghhav on February 17, 2010, 03:30:31 AM
yes please.
Title: Re: User must enter email twice during registration
Post by: kizer on February 27, 2010, 02:12:35 AM
This would be so nice to add to 2.0 RC2