Questions and Answers
As you can imagine, at WillMaster.com we receive a lot of
questions -- about our scripts and about CGI in general.
Questions are posted on the Q&A Forum at
/support/
and questions arrive as personal emails.
This article contains questions and their answers that I
believe some WillMaster Possibilities readers might learn
from. Most are paraphrased:
Q. I was wondering if it is possible to have two Master
Daily Content scripts on one web site for different
purposes. Shauna
A.
Yes, you can install multiple copies of Master Daily Content.
If appropriate in your situation, install them in separate
directories, like /cgi-bin/mdc1/ and /cgi-bin/mdc2/ On the
other hand, if the installations are in the same directory
then the program names must be different and the data
directories they use must have different names.
Q. I wonder if it is possible to make a form execute
two actions with the same value? Something like
"action=blah.cgi action=huh.cgi value="eek"." Zeb
A.
Zeb, while only one action="_____" can be specified, dual
action can be forced with the JavaScript onClick command.
Like this:
<form method="POST" action="script.cgi" onClick="MyJS()">
MyJS() can be a function to do whatever, including creating
a popup with a message. MyJS() must, however, return the
value "true" -- if "false" is returned then the normal
action="_____" tag won't execute.
Q. I am attempting to get the Master Webpage Mailer going.
I have specified the path to perl 5 on my system with
is /usr/bin, but it still isn't working. What am I
missing? Norris
A.
Your path to Perl might be /usr/bin/perl instead of /usr/bin
Also, there is a list of things to check at the
/support/faq/ page.
Q. I am using Recommend Pro 3.0 as a form in HTML email.
When sending the form, I get: "Your browser didn't
send me the URL of the form you're using..." I tried
to send it as a hidden field, but I am afraid that's
not the way to overcome the check in the script. How
may I use Referrer Pro in email? Wilhelm
A.
In order to use the recommend form in an email and have it
work every time, the referrer check must be disabled. Here
is how to to it:
At about line 47 of the script, you'll see:
unless($ENV{HTTP_REFERER})
Immediately above that line, type:
return 1;
You'll end up with:
return 1;
unless($ENV{HTTP_REFERER})
A note of WARNING: If you disable the referrer check,
anyone can use your installation of the script to spam
people. All they have to do is save the form to their own
hard drive (or create their own form) and fill in people's
names and addys, paste in their spam message, and click
the button. They could send it to hundreds of people
at a time.
Q. I know it is possible to insert variables into an html
file and have a CGI program fill them in, but don't know
how to do it. How would you do this from within a CGI
script? Judy
A.
Your script will first need to retrieve a template page.
That can be done by opening and reading the file or by
using the get function of module LWP::Simple.
Once the page is in your program (we'll assume the page
is in variable $Page), search $Page for placeholders and
replace them with custom information. For example, all
[[NAME]] placeholders might be replaced with a name
obtained via a form, with code similar to:
$Page =~ s/\[\[NAME\]\]/$FORM{name}/sg;
Once replacements are complete, the script prints the page
to the browser. Simply use:
print "Content-Type: text/html\n\n";
print $Page;
The HTML source code of template pages must use complete
http://... URLs instead of relative URLs for images, style
sheets, etc., because the server location of the CGI
program may be different than usual web pages (thus
breaking relative URLs).
Q. I've installed Master Recommend, and confirmed the
location of Perl (version 5+) and SendMail with my
web host. But when I submit the form, no emails get
sent. I've checked that the name and location of the
template file is correct. RE: Sendmail, I asked my host
about required flags and they said -t is optional. I've
tried it with and without -t, and neither worked. The
directory definitely has cgi access, and I'm confident
that the permissions are set correctly. Any other
suggestions as to why no emails get sent? Bob
A.
If the program works otherwise, then it is almost
certainly the path to sendmail that is in error. Use
Master Pre-Installation Tester from
/master/pit/
to see if the location you were given is indeed correct.
Note that the path to sendmail almost always begins with
a slash: /
Also, when you type the location in the globals.cgi file,
don't put it into quotes and don't follow it with a
semi-colon.
You're correct, Master Recommend can use sendmail whether
or not you specify the -t flag.
Q. I am sorry to bother you but HostPro sent me the
following message when I could not use Master Search.cgi
on their site. "I uploaded perldiver.cgi to your site to
see which PERL modules are currently installed and the
LWP::Simple is not. Could you please provide us with a
link to information about this module so that we may
setup a case to our admins to see if they will install
it." Please, could you help? Martin
A.
The page
http://search.cpan.org/search?mode=module&query=LWP
has several different distributions. Probably the one your
hosting company will decide to install on their servers is
"libwww-perl-5.53_94" by†Gisle Aas. Details about that
particular distribution are at
http://search.cpan.org/search?dist=libwww-perl
LWP::Simple is a module used by many Perl programs to fetch
pages from the net. I'm sure HostPro will see the benefit
of having it available for their hosting customers.
Q. Master Form works great! However, for drop down fields
where a response is required, somehow the user is able
to submit the form successfully without choosing an
option. The first field of the form is a selection
called "-Choose One-" and it has no value assigned to
it. How do I make this work correctly? Do I need to add
an extra validation? Monica
A.
Browsers tend to send the contents of the selection label
to the CGI program when no specific value is specified. In
other words, "-Choose One-" is being sent to the CGI script
as the value of the form field. Thus, Master Form thinks
the required field has been satisfied.
The solution is to specify a value="" (2 quotation marks
with nothing between them) for the form field labeled
"-Choose One-"
When a field is required, Master Form checks to see that
there is at least one word character (alphanumeric and a
few other printable characters) in the form field. A
value="" ensures there is no word character.
__________
That's it for this week :)
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]
Will Bontrager
©2001 Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.