Forum Moderators: coopster & phranque

Message Too Old, No Replies

Problem with submission form

         

Kaliedra

11:59 am on Feb 23, 2005 (gmt 0)

10+ Year Member



I'm having difficulty with getting a submission page to function. I've got the following code

<FORM ACTION="http://www.mysite.com/cgi-bin/form.pl" METHOD="POST">
<input type="hidden" name="your_email_address" value="myemail@yahoo.com">
<p><strong>
What about us do you want to contact us about?</strong></p>
<dl>
<dd><select name="Subject" size="1">
<option selected="">Membership</option>
<option>Website</option>
<option>(Other)</option>
</select> </dd>
</dl>
<p><strong>Use the space below to tell us how we can help:</strong></p>
<dl>
<dd><textarea name="Comments" rows="5" cols="45"></textarea></dd>
</dl>
<p><strong>Tell us how to get in touch with you:</strong></p>
<dl>
<dd>
<table>
<tbody>
<tr>
<td>Name</td>
<td><input type="text" size="35" maxlength="256" name="Username" /></td>
</tr>
<tr>
<td>E-mail</td>
<td><input type="text" size="35" maxlength="256" name="UserEmail" /></td>
</tr>
</tbody>
</table>
</dd>
</dl>
<p><input type="submit" value="Submit Form" />
<input type="reset" value="Clear Form" /></p>
</FORM>

After my fun experience with geocities I've moved over to tripod which supports cgi, but I'm not getting something right with the commands here because I get a Eroor 500 internal server error.

mikeyb

12:02 pm on Feb 23, 2005 (gmt 0)

10+ Year Member



Hi Kaliedra,

Well the internal server error 500 means there is something wrong in your form.pl script, not your HTML.

Your HTML looks fine.

Kaliedra

12:13 pm on Feb 23, 2005 (gmt 0)

10+ Year Member



Well that's a good start I guess. I'm using tripods cgi editing tools. Here's what i have for form.pl

#!/usr/local/bin/perl
#
# Author name:
# Creation date:
#
# Description:
#
require TripodCGI; # this is necessary to invoke the TripodCGI module,
# which is what we want to use here.
$CGI = new TripodCGI; # this creates an object via which we can
# use TripodCGI functions.

$subject = $CGI->param('Subject'); # this uses the param() function
$comments = $CGI->param('Comments'); # to assign the contents $username = $CGI->param('Username'); #of "yourname"
$useremail = $CGI->param('UserEmail');# to the variable $name.
#print "Content-Type: text/html\n\n"; # send an HTTP header
#print "<html><body>";# send the beginning of our page
#print "<h1>$comments</h1>";# print the value of $name, in big #type
#print "</body></html>";#close the tags; the end.

rocknbil

6:15 pm on Feb 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A couple of things:

Primarily for a script to run it has to send the content-type to the CGI gateway interface.

In any programming language, you can "remove" parts of it with what are called comments. For perl, that is any line or part of a line that begins with #.
So:

#print "Content-Type: text/html\n\n"; # send an HTTP header
#print "<html><body>";# send the beginning of our page
#print "<h1>$comments</h1>";# print the value of $name, in big #type
#print "</body></html>";#close the tags; the end.

This program will not tell the gateway it's content-type is text/html, or print anything out to the browser. Remove the beginning # from all of the above lines.

print "Content-Type: text/html\n\n"; # send an HTTP header
print "<html><body>";# send the beginning of our page
print "<h1>$comments</h1>";# print the value of $name, in big #type
print "</body></html>";#close the tags; the end.

(Actually that's not going to print the name as the comment says, it's going to print comments. as a level one head. :-) )

It may very well be sending the mail but just crashing when it tries to provide a response.

Next,

$comments = $CGI->param('Comments'); # to assign the contents $username = $CGI->param('Username'); #of "yourname"

The way this wraps is a function of this forum's display, correct? Otherwise this is all screwed up, and won't store the user name in $username:

$comments = $CGI->param('Comments');
# to assign the contents
$username = $CGI->param('Username');
#of "yourname"

^^ That will be fine.

Next, some basic stuff: I don't know how you get the files to your server, so if Tripod moves them for you the below is obsolete:

1. Upload your script in ASCII format, not binary. The end-of-line characters differ on various platforms.
2. Make sure the file permissions are set to EXECUTE. By default they are read-only. If you have access to command-line, this is chmod 755 form.pl (press enter.) If you don't, using ws_ftp, right-click the file and select chmod from the list, and X all the execute boxes.

Lastly, this will not cause it to stop functioning but is a Very Bad Idea:


<input type="hidden" name="your_email_address" value="myemail@yahoo.com">

This exposes your email addy to spiders but worse, tells a potential hacker that they can attempt to call the script from anywhere by sending a query to form.pl?your_email_address=address1@hackyou.com,address2@hackyou.com . . . .

Take this last one with a grain of salt as they **probably** have securiy methods in their programming to prevent the hack, but it still exposes your email addy.

Since I don't see a config for "your_email_address" in the script, it may be internal to their programming and not a whole lot you can do about it with this script.

Kaliedra

1:00 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



I'm not sure how it all works, its been a few years since I've had to do anything with perl so to say its rusty is an understatement. Ok I've made the changes in the last post and now when I hit submit it opens form.pl in the window and posts the contents of the text box. I obviously missed a command there.

rocknbil

3:07 am on Feb 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



LOL! I think that means it's working! But there's something I thought was working differently before. Did you check your email?

Let's break it down:

Create a place to store the incoming data (basically):
$CGI = new TripodCGI

Store it in variables, each predicated by $:
$subject = $CGI->param('Subject');
$comments = $CGI->param('Comments');
$username = $CGI->param('Username');
$useremail = $CGI->param('UserEmail');

HERE is where something is missing (I think.) See below.

NOW, give the browser a response:

print "Content-Type: text/html\n\n";
print "<html><body>";
print "<h1>$comments</h1>";
print "</body></html>";

Note the correlation between these three. in your form,
<textarea name="Comments"></textarea>

then here, storing that in $comments
$comments = $CGI->param('Comments');

Then look what prints out!
print "<h1>$comments</h1>";

So the "something missing" is where **I** would put any "send the mail" routines. I initially didn't say anything because I thought that was somehow managed by the unseen TripodCGI module.

But. By your description, the script is running. The steps to send the mail are missing if you're not getting mail. Something has been edit out, I think, which is pretty clear by the way those lines were munged up before.

Kaliedra

9:41 pm on Feb 25, 2005 (gmt 0)

10+ Year Member



Ok, I think I got it. I did get an email on one of my trials here so I'll go from that one. Thanks!