Email required field

Dr. GBooky is here to help you with your guestbook problems ...
Post Reply
PeteS
Posts: 8
Joined: Fri Mar 09, 2007 9:49 am

Email required field

Post 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?
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post 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

Code: Select all

$lang['t52']='Your e-mail:';
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
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
PeteS
Posts: 8
Joined: Fri Mar 09, 2007 9:49 am

Post 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.
DemonicIntolerance
Posts: 2
Joined: Mon Sep 28, 2009 12:40 pm

Post 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:

Code: Select all

$lang['t52']='Your e-mail:';
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
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post 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
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
DemonicIntolerance
Posts: 2
Joined: Mon Sep 28, 2009 12:40 pm

Post 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
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

Thanks for your help,
You're welcome

Henrie
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
Hugh Paulson
Posts: 2
Joined: Sat Apr 10, 2021 8:26 pm

Re: Email required field

Post 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:

Code: Select all

?>
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.
Post Reply