Can I make "email address" a required field?
Can I make "email address" a required field?
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
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
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.

$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.

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 !
Helena
btw, the guestbook can now be found at www.helenasoriginals.com , I JUST got the site up !
Okay, here it goes. Required e-mail address for GBook version 1.6
Edit file settings.php
AddPut it before /* DO NOT EDIT BELOW */
Edit file gbook.php
Search forand replace with (insert new code at line 98 )
Edit file language.inc.php
ChangeTo
and addPut it before ?>
Greetings,
Henrie
Edit file settings.php
Add
Code: Select all
/* Entering your e-mail is required? 1 = YES, 0 = NO */
$settings['req_email']=1;
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']);
}
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']);
}
Change
Code: Select all
$lang['t52']='Your e-mail:';
Code: Select all
$lang['t52']='<b>Your e-mail:</b>';
Code: Select all
$lang['hl_e01']='Please enter your e-mail address';
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.
Doesnt work for my 1,6
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
Parse error: syntax error, unexpected T_STRING in /hsphere/local/home/mysite.com/guests/gbook16/gbook.php on line 97
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 
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


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
Re: Can I make "email address" a required field?
I also got a parse error and did remove the last } from the script
Re: Can I make "email address" a required field?
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
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.