I have made a cgi feedback form for my website and before it prints the success page and sends an email I want the script to check for blank fields so I have added the following code:
if ($name eq "") {
&error();
}
if ($email eq "") {
&error();
}
if ($sitename eq "") {
&error();
}
if ($siteurl eq "") {
&error();
}
if ($sitedesc eq "") {
&error();
}
if ($banner eq "") {
&error();
}
if ($pass eq "") {
&error();
}
if ($contract eq "") {
&error();
}
if ($click eq "") {
&error();
}
if ($imp eq "") {
&error();
}
exit;
In &error(); is the following:
sub error {
print "Content-type: text/html \n\n";
print qq|
You forgot to fill in some fields!<BR>
|;
}
If the name field is the only blank one then this is ok as it says "You forgot to fill in some fields".
However if more than one field is blank it says "You forgot to fill in some fields!" for EACH blank field so the page looks like:
You forgot to fill in some fields!
You forgot to fill in some fields!
You forgot to fill in some fields!
You forgot to fill in some fields!
...and it also prints out: Content-type: text/html \n\n
So the error page ends up looking like:
You forgot to fill in some fields!Content-type: text/html \n\n
You forgot to fill in some fields!Content-type: text/html \n\n
You forgot to fill in some fields!Content-type: text/html \n\n
You forgot to fill in some fields!Content-type: text/html \n\n
How do I get around this?
Paul Wilson.
(Dont blame me if I'm wrong!)
if ($name eq "") {
&error();
}
if ($email eq "") {
&error();
}
if ($sitename eq "") {
&error();
}
if ($siteurl eq "") {
&error();
}
if ($sitedesc eq "") {
&error();
}
if ($banner eq "") {
&error();
}
if ($pass eq "") {
&error();
}
if ($contract eq "") {
&error();
}
if ($click eq "") {
&error();
}
if ($imp eq "") {
&error();
}
exit;
In &error(); is the following:
sub error {
print "Content-type: text/html \n\n";
print qq|
You forgot to fill in some fields!<BR>
|;
}
If the name field is the only blank one then this is ok as it says "You forgot to fill in some fields".
However if more than one field is blank it says "You forgot to fill in some fields!" for EACH blank field so the page looks like:
You forgot to fill in some fields!
You forgot to fill in some fields!
You forgot to fill in some fields!
You forgot to fill in some fields!
...and it also prints out: Content-type: text/html \n\n
So the error page ends up looking like:
You forgot to fill in some fields!Content-type: text/html \n\n
You forgot to fill in some fields!Content-type: text/html \n\n
You forgot to fill in some fields!Content-type: text/html \n\n
You forgot to fill in some fields!Content-type: text/html \n\n
How do I get around this?
Paul Wilson.
(Dont blame me if I'm wrong!)