Help with CGI form

Brooke's picture

She has: 681 posts

Joined: Feb 1999

Okay - the URL is: http://www.cwpp.org/survey.html

I have one of the scripts from Matt's Scripts archives that I am using. And everything is set up the way it directed - but the form is not working. If you click submit you will see the error I am getting. I was wondering if you had any ideas what's going on. The form is supposed to get emailed. (I have it being emailed to me right now so I make sure it's coming through okay).

I did use frontpage to make the form. But I have done that before using a cgi script and have not had any problems. I only have issues with this host. And they aren't helpful at all.

Thank for your help.

Brooke

------------------
Providing quality websites for businesses and individuals!
www.cataluna.com

They have: 334 posts

Joined: Dec 1999

A 500 error is sort of a catch-all CGI error message. It says something is wrong, but does nothing to help you find out what it is. If you have the server error logs that would help.

Since you're using a canned script, it's 99% likely that the script is okay and you just have it misconfigured.

5 things to check:

1) Upload the script in Ascii mode. Uploading in binary usually breaks it.
2) Check the shebang line, the one that reads something like "#!/usr/bin/perl" or "#!/usr/lib/perl". Make sure it's the correct path to Perl on your server.
3) Check file permissions. The script should be CHMod-ed to 755. Read the installation instructions for file permissions on any secondary files like logs, etc.
4) Check path to the files. That should be something like /home/username/public_html/cgi-bin or /usr/domain/www/cgi-bin or something similar. Make sure it's correct for your server path.
5) Check the line that's the path to sendmail. It should be something like /usr/sbin/sendmail or something similar. Again, make sure it's correct for your server.

I'd be willing to bet a huge sum of money that it's one of those 5 things that's causing the trouble. It almost always is.

Brooke's picture

She has: 681 posts

Joined: Feb 1999

Thank you so much. I will check to see which of those might be wrong.

Another questions. Sorry for the ignorance - I completely understand #1-3, but don't understand 4, and am unsure about 5. Could you explain those two parts to me?

Thanks.

Brooke

------------------
Providing quality websites for businesses and individuals!
www.cataluna.com

They have: 334 posts

Joined: Dec 1999

Okay, regarding #4 and #5. Your domain might be www.yourdomain.com, but that's not how the hosts server sees your site. To them, it's just a folder like Windows uses. Depending on how their server is set-up, you reside in a folder that has to do with your member name or company name. So, let's say when you signed on you chose membername as "brooke". You'd be in a folder named /home/brooke/public_html or in /usr/brooke/www or any of millions of other server paths. That's information you should have gotten when you signed up for the service. If you use an FTP client to upload files, look in the top of the remote server box (that's probably the one on the right in most FTP programs) when you log into your account. That will display the server path.

Near the top of most scripts there will be a line that tells the script how to find itself on the server. It'll read something like:
$basedir = '/home/brooke/public_html/cgi-bin/';

That line MUST be set to the correct path to where you placed the file on the server. If it's wrong, it'll get a 500 error EVERY time. It's the same thing is with the path to sendmail. Sendmail is a program that resides on the hosts server and .... <drumroll> ... sends out the mail. In this case you're using a script that's taking input and mailing it to you. So it needs to find the sendmail program to do so. You need to tell it where to look to find that program. Most hosts have it installed in either /usr/lib/sendmail or in /usr/sbin/sendmail. So you need to enter the right path into the script in a line like:
$mailprog = '/usr/sbin/sendmail';

Again, if the script can't find the Sendmail program when it tries to mail you you'll get a 500 error. Write your hosting company tech support to get the right paths to:
Perl
Sendmail
Date
cgi-bin
your file directories

All that information is 100% necessary to get CGI scripts working correctly and should already have been provided to you. If you don't have it, get it.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.