Page 1 of 1
Email required field
Posted: Wed Sep 02, 2009 10:12 am
by PeteS
Script URL:
Version of script: 1.7
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:
Write your message below:
Upgraded to version 1.7 from 1.6 and there is no longer any option to enforce email address entry as a required field. Is there any way of re-enabling this feature in 1.7?
Posted: Wed Sep 02, 2009 5:21 pm
by Henrie
Hello PeteS
Did you search the forum?
In version 1.6 this was not an option either, remember this post:
viewtopic.php?p=11054#11054 ?
But because this is a new version, here it goes:
Required e-mail address for GBook version 1.7
Edit file
settings.php
Add
Code: Select all
/* Entering your e-mail address is required? 1 = YES, 0 = NO */
$settings['req_email']=1;
Put it before
/* DO NOT EDIT BELOW */
Edit file
gbook.php
Search for (lines 778-782)
Code: Select all
if ($email=='INVALID')
{
$error_buffer .= $lang['e04'].'<br class="clear" />';
$email = '';
}
and replace with (insert new code at line 778)
Code: Select all
/* Required e-mail address modification by Henrie, now checks for required e-mail field as defined in settings file */
if ($settings['req_email'] == 1 && empty($email))
{
$error_buffer .= $lang['hl_e01'].'<br class="clear" />';
}
/* End of required e-mail address modification by Henrie, now checks for required e-mail field as defined in settings file */
if ($email=='INVALID')
{
$error_buffer .= $lang['e04'].'<br class="clear" />';
$email = '';
}
Edit file
language.inc.php
Change
To
Code: Select all
$lang['t52']='<b>Your e-mail:</b>';
and add
Code: Select all
$lang['hl_e01']='Please enter your e-mail address';
Put it before
?>
Greetings,
Henrie
Posted: Wed Sep 02, 2009 5:51 pm
by PeteS
Works an absolute treat - all I can say is thank you. Apologies for not hunting around for solution more before posting request and as I say, thank you.
Posted: Mon Sep 28, 2009 1:04 pm
by DemonicIntolerance
Hi, I'm a complete and utter n00b when it comes to coding, so when I looked at this, the amount of new coding just baffled me a bit. However, I looked at the coding myself and thought this might be a simpler method. It seemed to work for me, but I was wondering if anyone could check just to make sure its ok.
Edit
gbook.php
Origional:
Code: Select all
if ($email=='INVALID')
{
$error_buffer .= $lang['e04'].'<br class="clear" />';
$email = '';
}
New:
Code: Select all
if (empty($email))
{
$error_buffer .= $lang['e04'].'<br class="clear" />';
}
Then edit the
language.inc.php
Origional:
New:
Code: Select all
$lang['t52']='<b>Your e-mail:</b>';
This way you don't need to edit you settings.php file and you have less to add into the language.inc.php and gbook.php files as there is already an e-mail required error message in the language.inc.php file so you don't need to add your own. It also means you can edit the other fields in the same way without masses of coding. What do you guys think?
Regards,
Lee
Posted: Mon Sep 28, 2009 2:49 pm
by Henrie
Hello Lee,
This will only check for empty e-mail addresses, not for valid e-mail address. My example leaves the validity check intact and when it is used, it is also easy to set it back to not required just by changing a setting in the settings.php file.
If you would like to have the empty and validity check, change the code to something like
Code: Select all
if ($email=='INVALID'||empty($email))
{
$error_buffer .= $lang['e04'].'<br class="clear" />';
$email = '';
}
Bytheway, with your code you also need to change the following language string
Code: Select all
$lang['e04']='Enter a valid e-mail address or leave it empty';
to something that does not say that you can leave it empty because that is clearly not the case anymore.
Greetings,
Henrie
Posted: Mon Sep 28, 2009 3:55 pm
by DemonicIntolerance
Hi Henrie,
Thanks for that, it was a great help. I had actually changed the language string but forgot to actually say, haha, but thanks for pointing it out.
Thanks for your help,
Lee
Posted: Mon Sep 28, 2009 5:43 pm
by Henrie
Thanks for your help,
You're welcome
Henrie
Re: Email required field
Posted: Sun Apr 11, 2021 9:57 am
by Hugh Paulson
Thank you. I made these changes to
Gbook version 1.82 and they seem to be working without error.
The only thing is I did not find the following code within the language.inc.php file as indicated above:
So I added the new code of:
Code: Select all
$lang['hl_e01']='Please enter your e-mail address';
right after the line of code which says:
Code: Select all
$lang['t66']='E-mails are hidden from public';
and this seems to work fine too.