Click to See Complete Forum and Search --> : Looking for CGI script - yes, I searched


s1deus
10-03-2005, 11:56 AM
Ok, before anyone says to read the post at the top of the list, I DID. I downloaded some programs and I can't seem to get them to work.

What I am looking for is very simple (at least I think it is). I need a CGI script that writes to a datafile or text file, collecting a users info and email address, then redirecting the user to a Thank you page or error page if there is a problem.

Can someone point me to a better script or be willing to provide some code for me.

Thanks.

Nedals
10-04-2005, 02:08 PM
## I need a CGI script
use strict; ## ALWAYS
use CGI; ## standard module for working with 'web' pages
my $q = new CGI; ## Create a CGI object

## ...collecting a users info and email address,
my $userinfo = $q->param('userinfo'); ## from the HTML <input> fields
my $email = $q->param('email');
my $msg = '';

if ($userinfo and $email are ok) { ## NOT CODED - Test to make sure they are ok
## ...that writes to a datafile or text file,
my $filename = 'path/to/filename';
open (FIL,">$filename") || die "cannot create file, $!";
print FIL, "$userinfo:$email\n";
close (FIL);
$msg = 'Thank You';

} else { $msg = 'There is a problem'; }

## then redirecting the user to a Thank you page or error page if there is a problem.
print $q->header(); ## return HTTP headers and the web page
print <<HTML;
<html>
<head>
<title></title>
<head>
<body>
$msg
</body>
</html>
HTML

exit;

s1deus
10-07-2005, 02:26 PM
Thanks