Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My html form looks like this: <i

Status
Not open for further replies.

marybailey

Programmer
Mar 14, 2002
47
US
My html form looks like this:

<input type=checkbox name=active value=no>

On the perl side, I do this:

if ($Config{'active'} eq &quot;no&quot;) {
$active=0; }
else
{ $active=1;}

Then I call this:

sub return_html {

if ($active == 1) {
print &quot;Content-type: text/html\n\n&quot;;
print &quot;<HTML>\n&quot;;
print &quot;<BODY BGCOLOR=#FFFFFF>\n&quot;;
print &quot;<CENTER>\n&quot;;
print &quot;<img src=\&quot;http:\/\/ print &quot;<BR><BR>Thank you for joining our mailing list, $Config{'realname'}\n&quot;;
print &quot;<P>\n&quot;;
print &quot;Your emails will be sent to $Config{'email'}\n&quot;;
print &quot;<\/CENTER>\n&quot;;
print &quot;</BODY>\n&quot;;
print &quot;</HTML>\n&quot;;
}
}

THE PROBLEM IS WHEN I CHECK THE CHECKBOX SO ITS VALUE IS NO I GET THE INFAMOUS 500 INTERNAL SERVER ERROR. IF I LEAVE IT BLANK EVERYTHING RUNS AS EXPECTED. WHEN I PRINT OUT THE VALUE OF ACTIVE ITS AS EXPECTED: 1 OR 0.

What am I doing wrong?
Thanks,
Mrs B
 
I don't know what the problem is but I know a simpler way to print the HTML without all of the backslashes.
Code:
print <<EOF;
Content-type: text/html\n
<HTML>
<BODY BGCOLOR=#FFFFFF>
<CENTER>
<img src=&quot;[URL unfurl="true"]http://www.chezfrancoisrest.com/images/chefr.jpg&quot;;>[/URL]
<BR><BR>Thank you for joining our mailing list, $Config{'realname'}
<P>
Your emails will be sent to $Config{'email'}
</CENTER>
</BODY>
</HTML>
EOF
 
... and/or an explaination of what its supposed to do.

Off the bat it looks like you need an else{} statement to go with your if() statement inside the return_html() subroutine. You need to return some html regardless of whether or not the checkbox has been selected. You always have to return something, otherwise its the same as a link to a page that doesn't exist.

But this is based only on the code you have poseted so far.

jaa
 
The checkbox only returns a value if it is checked. You can test to see if the checkbox is checked using a javascript. However, if the checkbox is unchecked, the 'active' value doesn't exist, so you have to test to see if the variable exists before testing whether or not its value is 'no' or not. I.e.:

if ($Config{'active'} && $Config{'active'} eq &quot;no&quot;) {
# do stuff...
}

not sure if this works but I believe that's what's happening. If it doesn't work, let me know and I'll test it out myself and give you the real answer.
Steve Kiehl
webmaster@nanovox.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top