PDA

View Full Version : 403 no variable substitutions in template error


mkphoto44
02-11-2006, 05:28 PM
I am new to the CGI scripts and I am trying to set up a form on a web stie. I keep getting the error message:

403 no variable substitutions in template
/home/mlkpoto/public_html/form.html

my script is as follows:

<form action="http:/photosbymlkeen.com/cgi-bin/cgiecho/form.html" method="POST" name="Feedback_Form">

<table align="center" border="0"><tr>
<td align="right">First Name</td><td align="left"><input type="text" size="20" maxlength="72" name="FirstName1"></td></tr>
<tr><td align="right">Last Name</td>
<td align="left"><input type="text" size="20" maxlength="72" name="LastName2"></td></tr>
<tr><td align="right">Wedding Date</td>
<td align="left"><input type="text" size="20" maxlength="72" name="WeddingDate3"></td></tr>
<tr><td align="right">City</td>
<td align="left"><input type="text" size="20" maxlength="72" name="City__4"></td></tr>
<tr><td align="right">State</td>
<td align="left"><input type="text" size="20" maxlength="72" name="State__5"></td></tr>
<tr><td align="right">Zip Code</td>
<td align="left"><input type="text" size="20" maxlength="72" name="Zip_Code__6"></td></tr>
<tr><td align="right">Daytime Phone</td>
<td align="left">(<input type="text" name="npa_Daytime_Phone__7" size="3" maxlength="3">) <input type="text" name="nxx_Daytime_Phone__7" size="3" maxlength="3">-<input type="text" name="last4digits_Daytime_Phone__7" size="4" maxlength="4"></td></tr>
<tr><td align="right">Evening Phone</td>
<td align="left">(<input type="text" name="npa_Evening_Phone__8" size="3" maxlength="3">) <input type="text" name="nxx_Evening_Phone__8" size="3" maxlength="3">-<input type="text" name="last4digits_Evening_Phone__8" size="4" maxlength="4"></td></tr>
<tr><td align="right">E-mail Address</td>
<td align="left"><input type="text" size="20" maxlength="72" name="E-mail_Address__9"></td></tr>
<tr align="center">
<td colspan="2"><input type="submit" value="Send" name="Send"><td>
</tr>
<input type="hidden" name="ThankYou" value="http://photosbymlkeen.com/ThankYou.html"></table>
</form>

FishMonger
02-11-2006, 06:01 PM
From your action statement, it appears that you're trying to have a plain html file process the form...that won't work. You need to submit the form to a script not an html file. If your form submission script is written in Perl, the extension should be .pl or .cgi not .html.

mkphoto44
02-11-2006, 06:05 PM
okay - since I'm very new to this. How do I do that? Do I just change the extension on the file or is the code written differently? Thanks for your help.

FishMonger
02-11-2006, 06:24 PM
No, you can't just change the extension and turn an html file into a Perl cgi script, they are completly different.

Here's the beginning portion of a script to parse your form.

#!/usr/bin/perl

use warnings;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);

my $cgi = new CGI;
my %form = $cgi->Vars;

print $cgi->header;
warningsToBrowser(1);
print $cgi->start_html;

# now lets print out each form field

foreach my $field (keys %form) {
print "$field -> $form{$field}\n";
}

print $cgi->end_html;
This might be some help: http://www.cgi101.com/

mkphoto44
02-11-2006, 06:43 PM
you have lost me - totally. Is this a seperate file from the one on the webpage itself? I don't mean to be stupid but this is all new to me and I want to learn the right way to build these forms. Thanks again for your help.

FishMonger
02-11-2006, 07:03 PM
Yes, they are completly separate files. The html form is placed in your /home/mlkpoto/public_html/ directory and the script is placed in your cgi-bin/cgiecho/ directory.

They can be combined into 1, in which case the cgi script includes and prints the form. I need to go to work, so I don't have time to show you how to combine them, but check out the link to cgi101 that I posted. I would also highly recommend picking up (at least) these 2 books.

Learning Perl
http://www.oreilly.com/catalog/learnperl4/

CGI Programming with Perl
http://www.oreilly.com/catalog/cgi2/

List of other interesting Perl books.
http://www.oreilly.com/pub/topic/perl