Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Form & CGI-BIN

Status
Not open for further replies.

Wetall

Programmer
Aug 12, 2004
1
US
I've only been programming for 6 months now, and haven't gotten a chance to work with Perl, however I was asked to make a friend of mine a Web Form for users of his website to submit info to him. Well, I made the form easily enough, but now I need to get it send the info somewhere. His web hosting has a CGI-Bin for me to put the Post-Query info in, but I don't know how to make that stuff. Is there any tutorials you know of that will tell me how to do this step by step, or even just an example of a working post-query would work so I can at least look at it and figure it out. Well, thanks for any help you can give me, feel free to either email me or IM me on AIM if it makes it easier for you otherwise I'll keep checking back here.
 
Here's q quick example of emailing form contents:

Code:
[COLOR=red]#!/usr/local/bin/perl[/color]

use CGI qw(param);
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

#set up variables from passed form values
my $name = param("name");
my $addr = param("address");
my $city = param("city");
my $st = param("state");
my $zip = param("zip");
my $email = param("email");
my $operations = '[COLOR=red]you@yoursite.com[/color]';
my $mailprog = '[COLOR=red]/usr/lib/sendmail[/color]';
print "Content-type: text/html\n\n";	
		
open MAIL, "| $mailprog -t -i" or die "Couldn't open Mail Program: $!";

print MAIL <<END_OF_MESSAGE;
To: $operations
From: $email
Subject: Form Information

Name: $name
Address: $addr
City: $city
State: $st
Zip Code: $zip
Email: $email 
	 
END_OF_MESSAGE

close MAIL or die "Couldn't close Mail Program: $!";

The items in red will need to be verified and possibly changed to match your particular needs. Also, this assumes that you friend's hosting company will give you access to sendmail.

Good luck.

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top