Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

cgi form won't submit

Posted on 2001-08-28
5
Medium Priority
?
358 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Expert Comment

by:bigbed
ID: 6435642
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
ID: 6437663
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 200 total points
ID: 6439687
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
ID: 6440118
you need to tell your server that .cgi is a valid extension for CGI-Scripts.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6699380
Finalized
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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 how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

610 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