Perl Guestbook Script question

  • amber
  • Born
  • Born
  • amber
  • Posts: 3

Post 3+ Months Ago

Hello,

My name is amber. (waits for the group "hello amber")

I'm not here for a scripters anonymous meeting, but I do have a question if anyone is of a mind to help.

The Guestbook Script is awesome. However, I really know next to nothing about CGI and cannot figure out how to make certain fields mandatory, or take away the mandatory designation.

For example, I want e-mail to be mandatory, but right now, I am able to submit without an email address. I also don't want city to be mandatory or give the visitor an error if they choose to leave it blank. Is this possble? Who am I kidding. Of course it's possible - but would anyone out there in OZZU world be willing/able to help?

Thankful for any tidbit or breadcrumb tossed my way.


Feeling like I've entered a fairy tale...
amber
  • Managedlinks
  • Proficient
  • Proficient
  • Managedlinks
  • Posts: 294

Post 3+ Months Ago

Hi Amber Welcome, this is a great place I have only been here a couple of weeks myself and it feels like a second home already :)

which guestbook script ? the one advertised here from bigwebmaster ?

I do have a custom filter I have developed that does exactly what you need. adding a "Required" field is as easy as typing its name. you can also create other rules for the field for example determining if an email address is valid or checking a URL actually exists etc...
  • amber
  • Born
  • Born
  • amber
  • Posts: 3

Post 3+ Months Ago

Thank you for replying,

My apologies. Yes, the guestbook script is the one by bigwebmaster. I should have been more clear.

I am interested in the filter you described. However, it was my understsanding that the script already does some validation. It's not been something I've been able to delve too deeply into yet, though.

Thanks for the offer.


Peers through the looking glass and smiles,
amber
  • Managedlinks
  • Proficient
  • Proficient
  • Managedlinks
  • Posts: 294

Post 3+ Months Ago

I just took a look at the script

the validation routines only work if someone has actually entered something.

the routines are in the "checkdata" function in addguest.cgi

if you are not planning to write lots of scripts you are better off just modding the existing addguest.cgi script

for example change the part that says
Code: [ Select ]
elsif (($email ne "") && ($email !~ /\@/ || $email !~ /\./)) {
$homepage = "http://$homepage";
$errormsg = "You have not entered a valid email address";
&displayerror;
}
  1. elsif (($email ne "") && ($email !~ /\@/ || $email !~ /\./)) {
  2. $homepage = "http://$homepage";
  3. $errormsg = "You have not entered a valid email address";
  4. &displayerror;
  5. }
to ...
Code: [ Select ]
elsif (!$email || $email !~ /\@/ || $email !~ /\./) {
$homepage = "http://$homepage";
$errormsg = "You have not entered a valid email address";
&displayerror;
}
  1. elsif (!$email || $email !~ /\@/ || $email !~ /\./) {
  2. $homepage = "http://$homepage";
  3. $errormsg = "You have not entered a valid email address";
  4. &displayerror;
  5. }


to make email a required field

the above first checks to see if email is defined and not blank, then it checks to see if it contains a @ symbol then it checks to see if it contains a dot.

that is a very crude check but it will do for a simple guestbook
  • amber
  • Born
  • Born
  • amber
  • Posts: 3

Post 3+ Months Ago

Thank you. That did work. There are other things that need to be tweaked, but I think I can take care of those myself.

You've been very helpful and kind. It is much appreciated.


Happy on the yellow brick road,
amber

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 120 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.