Page 1 of 1

Can I make "email address" a required field?

Posted: Fri Jul 29, 2005 11:56 am
by Helena
Script URL:
Version of script: 1.33
Version of PHP:
Hosting company: www.surftown.com
Have you searched THIS FORUM for your problem: yep
(if not please do before posting)
If so, what terms did you try: required field

Write your message below:

I don't know anything about PHP but managed to install and to some extent customize the view of the guestbook and now I'm wondering if I can make the "email address" field a required field ?

Thanks for a great free script !

Helena

Posted: Fri Jul 29, 2005 2:02 pm
by Guest
hi, find this portion of code

$name=htmlspecialchars(stripslashes("$_REQUEST[name]"));
if(empty($name)) {problem("Please enter your name!","1");}
$from=htmlspecialchars(stripslashes("$_REQUEST[from]"));
$a=check_mail_url(); $email=$a['email']; $url=$a['url'];
$comments=htmlspecialchars(stripslashes("$_REQUEST[comments]"));
if(empty($comments)) {problem("Please enter your comments!","1");}
$isprivate=$_REQUEST['private'];

_____________________________________________

and replace with this code, (added bits are highlighted),
_____________________________________________

$name=htmlspecialchars(stripslashes("$_REQUEST[name]"));
if(empty($name)) {problem("Please enter your name!","1");}
$email=htmlspecialchars(stripslashes("$_REQUEST[email]"));
if(empty($email)) {problem("Please enter your email!","1");}

$from=htmlspecialchars(stripslashes("$_REQUEST[from]"));
$a=check_mail_url(); $email=$a['email']; $url=$a['url'];
$comments=htmlspecialchars(stripslashes("$_REQUEST[comments]"));
if(empty($comments)) {problem("Please enter your comments!","1");}
$isprivate=$_REQUEST['private'];

now your email is a required feature, it will also ask for a valid email of sorts, although we all know it only requires an @ and a . more or less.

good luck

if you do not know how to do this, open up gbook.php wih say "notepad" and search for the top portion of code and replace with the newer lower version of the code.

:wink:

Posted: Fri Jul 29, 2005 4:02 pm
by Guest
I'll try that, thank you so much !


Helena


btw, the guestbook can now be found at www.helenasoriginals.com , I JUST got the site up !

Posted: Sun Jul 05, 2009 12:06 pm
by PeteS
How can we make email address a required field in 1.6?

Posted: Sun Jul 05, 2009 8:37 pm
by Henrie
Okay, here it goes. Required e-mail address for GBook version 1.6

Edit file settings.php
Add

Code: Select all

/* Entering your e-mail is required? 1 = YES, 0 = NO */
$settings['req_email']=1;
Put it before /* DO NOT EDIT BELOW */

Edit file gbook.php
Search for

Code: Select all

        if (empty($name))
        {
            printSign($name,$from,$email,$url,$comments,$sign_nosmileys,$sign_isprivate,$lang['e03']);
        }
        if ($email=='INVALID')
        {
            printSign($name,$from,'',$url,$comments,$sign_nosmileys,$sign_isprivate,$lang['e04']);
        }
and replace with (insert new code at line 98 )

Code: Select all

        if (empty($name))
        {
            printSign($name,$from,$email,$url,$comments,$sign_nosmileys,$sign_isprivate,$lang['e03']);
        }
        /* Start required fields modification by Henrie, now checks for required e-mail field as defined in settings file */
        if ($settings['req_email'] == 1 && empty($email))
        {
            printSign($name,$from,'',$url,$comments,$sign_nosmileys,$sign_isprivate,$lang['hl_e01']);
        }
        /* End required fields modification by Henrie, now checks for required e-mail field as defined in settings file */
        if ($email=='INVALID')
        {
            printSign($name,$from,'',$url,$comments,$sign_nosmileys,$sign_isprivate,$lang['e04']);
        }
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

Posted: Mon Jul 06, 2009 8:19 pm
by PeteS
Absolutely superb - works a treat, thank you very much!

--
Bike Bash

Doesnt work for my 1,6

Posted: Sun Aug 09, 2009 7:02 pm
by Wulfgen
I get this error when I add the code to the gbook.php on line 98

Parse error: syntax error, unexpected T_STRING in /hsphere/local/home/mysite.com/guests/gbook16/gbook.php on line 97

Posted: Sun Aug 09, 2009 7:55 pm
by Klemen
It's a syntax error, post your lines 90 to 110 here and I will check them.

Re: Can I make "email address" a required field?

Posted: Sun Oct 07, 2012 3:09 pm
by sgleiden
I also got a parse error and did remove the last } from the script

Re: Can I make "email address" a required field?

Posted: Sun Oct 07, 2012 3:29 pm
by Henrie
Hello sgleiden,

Are you still using GBook version 1.6?
You should better upgrade to version 1.7
For modifications like the requiered email address available for GBook version 1.7, see this post viewtopic.php?f=3&t=371

Greetings,
Henrie