# ---- Main program ----
my $query = new CGI;
if ($query->param) {
if ($query->param('max_resume_size')) {
$max_resume_size = $query->param('max_resume_size');
}
if ($query->param('domain')) {
$domain = $query->param('domain');
}
if ($query->param('redirect')) {
$redirect = $query->param('redirect');
}
if ($query->param('site_home')) {
$site_home = $query->param('site_home');
}
else {
if ($ENV{HTTP_REFERER} =~ /http:\/\/(.*?)\/(.*?)/i) {
$site_home = 'http://'.$1;
}
else {
if ($ENV{SCRIPT_NAME} =~ /http:\/\/(.*?)\/(.*?)/i) {
$site_home = 'http://'.$1;
}
}
}
}
else {
print $query->header(-cache => 'no');
print("<html><title><Error></title><body><h2>We are sorry but this is an invalid request.</h2></body></html>\n");
exit;
}
# Some logic to find the file name.. This assumes that the script file is placed
# in the same directory as the html file.
#Redundant method of finding file name of the application form.
#This always assumes that the file is in the same directory as form
my $file = "";
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
print '<CENTER><TABLE width="100%" border=0>' if ($MAIL{'debug'});
my @VAL = $query->param;
$MAIL{'message'} = "ENV_REMOTE_ADDRESS = $ENV{'REMOTE_ADDR'}\n";
$MAIL{'message'} .= "ENV_CONTENT_LENGTH = $ENV{'CONTENT_LENGTH'}\n";
$MAIL{'message'} .= "\n--START_OF_DATA--\n\n";
my @emptyvariables;
foreach (@VAL) {
print '<tr><td align = left>',$_, '</td><td align=center> ====> </td><td align=left>', $query->param($_),'</td></tr>' if ($MAIL{'debug'});
if ($_ =~ /^\*(.+)/) {
if ((!$query->param($_)) ¦¦ ( $_ =~ /state/i && length($query->param($_)) ne 2)) {
push(@emptyvariables, $1 );
}
}
$MAIL{'message'} .= $_;
$MAIL{'message'} .= ' = ';
$MAIL{'message'} .= $query->param($_);
$MAIL{'message'} .= "\n";
}
&mail();
print $query->header;
print '<h3><P>Thank you for your form submission. You will be hearing from us shortly.</P></h3>';
print "<P>Return to our <A HREF=\"$site_home\">Home Page</A>.</P>";
print $query->end_html;
exit;
[edited by: phranque at 11:28 pm (utc) on Sep. 22, 2009]
[edit reason] cleaned up extraneous comments [/edit]
for debugging purposes i would move the "print $query->header;" statement toward the beginning of the code.
if you print anything to STDOUT before the header your page won't display since it is not providing a proper HTTP response.
if it is hanging up in the "mail" routine that's a different issue, but you aren't showing that code so no way to tell.
WebmasterWorld Member Guidelines on Posting Code. [webmasterworld.com]