Solved

cgi form won't submit

Posted on 2001-08-28
5
349 Views
Last Modified: 2013-12-25
I have a cgi form problem I hope you can help me with. I am a web designer and one of my
clients has a web site (that someone else did) which has an online request
form. The client says that the submit button doesn't work but used to. When
I try to submit the form I get a page with this message:

"501 Not Implemented

We are sorry to be unable to perform the method POST to non-script at this
time or to this document."

The URL of the form is
http://www.dkbhomes.com/customerservice/CustomerService.html and the cgi
script is included in this email below. I would appreciate any advice you
have.

Thank you
rcolby

-----------------


#!/usr/bin/perl

########################################################################
# CGI Variables
# name - person submitting form
# address - person's address
# city
# zip
# workphone
# homephone
# description1
# description2
# description3
# description4
# description5
# description6
# description7
# description8
# description9
# description10
# desc1length
########################################################################

# Mail destination appears as first parameter to sendmail command
# To: line is so that it appears in the text of the email.
# Include Reply-To: name if want user to be able to click reply
# button and have it directed back to sender.

use CGI qw(param);

print <<END_of_part1;
Content-type: text/html


END_of_part1

my $name = param("name");
my $address = param("address");
my $city = param("city");
my $workphone = param("workphone");
my $homephone = param("homephone");
my $altphone = param("altphone");
my $description1 = param("description1");
my $description2 = param("description2");
my $description3 = param("description3");
my $description4 = param("description4");
my $description5 = param("description5");
my $description6 = param("description6");
my $description7 = param("description7");
my $description8 = param("description8");
my $description9 = param("description9");
my $description10 = param("description10");
chomp($name);
chomp($address);
chomp($city);
chomp($workphone);
chomp($homephone);
chomp($altphone);
chomp($description1);
chomp($description2);
chomp($description3);
chomp($description4);
chomp($description5);
chomp($description6);
chomp($description7);
chomp($description8);
chomp($description9);
chomp($description10);


#change the To: field to wherever you would like the results
#of the survey sent

open (MAIL, "| /usr/sbin/sendmail sbyron\@landd.COM") || mail_failure();
print MAIL "To: sbyron\@landd.COM\n";
print MAIL "From: Web Server\n";
print MAIL "Subject: DKB Homes Request For Service Form\n\n";

print MAIL "                          REQUEST FOR SERVICE\n\n";
print MAIL "TO:  L&D CONSTRUCTION CO., INC.\n";
print MAIL "     255 W. Julian Steet, Suite 200\n";
print MAIL "     San Jose, CA 95110\n\n";

print MAIL "Name: $name\n";
print MAIL "Address Request for Service: $address\n";
print MAIL "City: $city\n";
print MAIL "Work Phone: $workphone\n";
print MAIL "Home Phone: $homephone\n";
print MAIL "Alternate Phone: $altphone\n\n";

print MAIL "ITEM NO.         DESCRIPTION:\n\n";      

if ($description1 ne ""){
 print MAIL "   1.            $description1\n\n";
}

if ($description2 ne ""){
 print MAIL "   2.            $description2\n\n";
}

if ($description3 ne ""){
 print MAIL "   3.            $description3\n\n";
}

if ($description4 ne ""){
 print MAIL "   4.            $description4\n\n";
}

if ($description5 ne ""){
 print MAIL "   5.            $description5\n\n";
}

if ($description6 ne ""){
 print MAIL "   6.            $description6\n\n";
}

if ($description7 ne ""){
 print MAIL "   7.            $description7\n\n";
}

if ($description8 ne ""){
 print MAIL "   8.            $description8\n\n";
}

if ($description9 ne ""){
 print MAIL "   9.            $description9\n\n";
}

if ($description10 ne ""){
 print MAIL "   10.           $description10\n\n";
}

close (MAIL);

print <<END_of_last_part;

<html>
<head>
<title>Mail SuperLoans.com update form results</title>
</head>
<BODY link="#238456" vlink="#238456" bgcolor="#508F9F">
<BR><BR><BR>
<H3><center>$name</center></H3>
<H3><center>Your Request Has Been Sent</center></H3>
</BODY>
</HTML>
END_of_last_part

sub mail_failure{
  print "Cannot find mail program.  Please email amie\@sv1.com if you wish
to report this problem.";
  exit;
}



0
Comment
Question by:rcolby
5 Comments
 
LVL 3

Expert Comment

by:bigbed
Comment Utility
Couple of things.
In your form html you have:
<FORM name="request" action="requestform.cgi" ENCTYPE=x-www-form encoded method=post>

Your ENCTYPE is wrong I think.
Since it is the default type you seem to want, you don't need it.
If you really want to keep it, change it to
ENCTYPE="application/x-www-form-urlencoded"
note the quotes.

Also the error states that it can't post to 'non-script'.
This implies that maybe it doesn't think your script is executable?  Check the permissions on the script, perhaps change them to 755 (rwxr-xr-x).

Hope this helps
0
 

Author Comment

by:rcolby
Comment Utility
Bigbed,

Thank you for your response to my question. I tried replacing the ENCTYPE with the one you provided and the form will submit, but the browser takes me to a page that displays the cgi script and I don't receive the form results in my email. I'm no longer getting the "501" error, but it's still not working. Also, being somewhat unfamiliar with cgi, I'm not sure where to find the permissions in the script to change them. Can you tell me where to find that?

Thank you,
rcolby
0
 
LVL 3

Accepted Solution

by:
bigbed earned 50 total points
Comment Utility
sounds like the web server isn't recognising that it is a cgi script.

This could be several things:
1. permissions on the script not set, so script is not executable.  Try changing the script permissions to allow this (chmod 755 requestform.cgi   or chmod a+x requestform.cgi);

2. web server only allows cgi to run in certain directories.  I *think* you will need to look for ScriptAlias and Options directives in the web server config (assuming you are using apache!).  Usually there will be a ScriptAlias cgi-bin directive, meaning that the .cgi has to be in a directory called cgi-bin.  Alternatively, under the <Directory /> section there may be an Options directive.  If it says Options ExecCGI, then you *should* be allowed to run cgi's anywhere.

3. web server may not be allowing cgi's to run at all (unlikely).  I *think* this is controlled by the ScriptAlias directives in the apache config.

I suspect the most likely is 2.

I'm sorry if you're not using apache I have no clue (most would say I have no clue anyway!)

Good luck
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
you need to tell your server that .cgi is a valid extension for CGI-Scripts.
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Finalized
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now