Can I make "email address" a required field?

Dr. GBooky is here to help you with your guestbook problems ...
Post Reply
Helena
Posts: 1
Joined: Fri Jul 29, 2005 11:40 am

Can I make "email address" a required field?

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

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

Post 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 !
PeteS
Posts: 8
Joined: Fri Mar 09, 2007 9:49 am

Post by PeteS »

How can we make email address a required field in 1.6?
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

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

Absolutely superb - works a treat, thank you very much!

--
Bike Bash
Wulfgen
Posts: 2
Joined: Sun Aug 09, 2009 6:59 pm

Doesnt work for my 1,6

Post 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
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

It's a syntax error, post your lines 90 to 110 here and I will check them.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
sgleiden
Posts: 2
Joined: Sun Oct 07, 2012 12:26 pm

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

Post by sgleiden »

I also got a parse error and did remove the last } from the script
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

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

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