cgi script - for sending a form

liunx

Guest
I need to make a form and have people fill out information then click submit and then it be emailed to me. I heard its best to use a cgi script. can someone walk me through it? Please tell me where to get the cgi script and how to put it in my html form.<br />
<br />
thanks<br />
chris<!--content-->Who told you cgi? It can be done with any server side language and depending on ur mail provider it can be done client side too. First thing you need to do is see what your host supports. Who is your host?<!--content-->I am with earthlink.net. it supports cgi. I have a cgi-bin folder on my server. See different people are going to be accessing my this form from different computers. I just heard cgi scripts work better but I dont care as long as it works and when the information gets email to me it is clear and organized!<!--content-->I dont use perl/cgi myself but I can give you the html part of it, do you need that? Or just the perl.<!--content-->um, I dont know which part I need. all I have is the form that goes into the html. I know nothing else so you would have to walk me through it please.<!--content-->php (php.net) would be my first choice if you want to write your own server-side stuff.<br />
<br />
Or, you might find a ready-made perl script to slot into your cgi bin on hotscripts.com.<!--content-->Heres a cgi form script. <br />
<br />
Place this script in your cgi-bin directory. In your html form, you will need to write the following code.<br />
<form method="post" action="location of cgi script"><br />
<INPUT TYPE="hidden" NAME="submitaddress" VALUE="your email"><br />
<br />
#!/usr/bin/perl<br />
<br />
# That is the path to PERL just above It MUST be first in the script<br />
# The following accepts the data from the form<br />
<br />
if ($ENV{'REQUEST_METHOD'} eq 'POST') {<br />
<br />
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});<br />
<br />
@pairs = split(/&/, $buffer);<br />
<br />
foreach $pair (@pairs) {<br />
($name, $value) = split(/=/, $pair);<br />
$value =~ tr/+/ /;<br />
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;<br />
<br />
$FORM{$name} = $value;<br />
}<br />
<br />
<br />
<br />
# The following sends the email<br />
<br />
open (MESSAGE,"| /usr/lib/sendmail -t");<br />
<br />
print MESSAGE "To: $FORM{submitaddress}\n";<br />
print MESSAGE "From: $FORM{name}\n";<br />
print MESSAGE "Reply-To: $FORM{email}\n";<br />
<br />
print MESSAGE "Subject: $FORM{selection} $ENV{'REMOTE_HOST'}\n\n";<br />
print MESSAGE "The user wrote:\n\n";<br />
print MESSAGE "$FORM{feedback}\n";<br />
close (MESSAGE);<br />
<br />
&thank_you;<br />
}<br />
<br />
<br />
<br />
<br />
#The following creates the Thank You page display<br />
<br />
sub thank_you {<br />
<br />
print "Content-type: text/html\n\n";<br />
print "<HTML>\n";<br />
print "<HEAD>\n";<br />
print "<TITLE>Thank You!</TITLE>\n";<br />
print "</HEAD>\n";<br />
print "<BODY BGCOLOR=#FFFFCC TEXT=#000000>\n";<br />
print "<H1>Thank You!</H1>\n";<br />
print "\n";<br />
print "<P>\n";<br />
print "<H3>Your $FORM{selection} is greatly appreciated.<BR>\n";<br />
print "<P>\n";<br />
print "<h3>You wrote: $FORM{feedback}.<br>\n";<br />
print "</BODY>\n";<br />
print "</HTML>\n";<br />
exit(0);<br />
}<!--content-->hey gokou, do you have aim or icq i could chat with you about this? i need some help with this thing too.. thanks<!--content-->gokou<br />
# The following accepts the data from the form <br />
<br />
if ($ENV{'REQUEST_METHOD'} eq 'POST') { <br />
<br />
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); <br />
<br />
@pairs = split(/&/, $buffer); <br />
<br />
foreach $pair (@pairs) { <br />
($name, $value) = split(/=/, $pair); <br />
$value =~ tr/+/ /; <br />
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; <br />
<br />
$FORM{$name} = $value; <br />
}<br />
This form parser is incorrect/incomplete and does not validate under strict and warnings.<br />
use CGI qw{param};<br />
# now parameters are retrieved with param('name')<br />
# rather than $FORM{name}<br />
if ($ENV{'REQUEST_METHOD'} eq 'POST')This test is now unecessary.<!--content-->If you don't care what method you use, try this. Just add this code inside your <form> tag:<br />
<br />
action="mailto:[email protected]" method="POST" enctype="text/plain" name="formnamegoeshere"<br />
<br />
You might want to add a notice to the user not to click "Submit" more than once, or they might send you form results numerous times.<br />
<br />
No point in making things complicated if it isn't neccessary.<br />
<br />
<br />
Aronya1<!--content-->
 
Back
Top