PDA

View Full Version : An HTML page exit out of a form


WizardWorkz
01-07-2004, 11:08 PM
Hey Everyone... I'm finally falling down and giving up... can anyone tell me why this will not automatically redirect to the HTML page I have at the bottom of this script?


#!/usr/bin/perl -w
use strict;
use CGI ':standard';
#####################################################
##This script was programmed by Virgil G. Mandanici #
##at WizardWorkz www.wizardworkz.com #
##.....gimme a link if ya can! #
#####################################################

my $email;

my $to;
my $from;
my $subject;
my $message;
my $sendmail;
my $sendmailpath;

$email = param('email');


$to = param('to');
$from = param('from');
$subject = param('subject');
$message = param('message');
$sendmail = param('sendmail');
$sendmailpath = param('sendmailpath');


$from="email";
$to="virgil\@wizardworkz.com";
$subject="Someone requested documents";

$sendmailpath="/usr/sbin/sendmail";



$message = "Here is the contact info from your web site\n
Email: $email\n


Add to your mailing list Virgil! \n";


open (SENDMAIL, "| $sendmailpath -t") or die "Cannot open $sendmail: $!";

print SENDMAIL "Subject: $subject\n";
print SENDMAIL "From: $email\n";
print SENDMAIL "To: $to\n\n";

print SENDMAIL "$message";
close (SENDMAIL);


open(HTML,"<http://www.dogtrax.net/freeMusica.html");



#### I don't know why it won't work. Any help would be really appreciated.

Thanks!;)

grafman
01-28-2004, 04:50 PM
hello,

Your use of the open() call is not correct in the given context.

The code:

open(HTML,"http://some.web.site");

tries to open a "file" called "http://some.web.site")

You need to make sure to use the LWP and HTML modules

use LWP;
and
use HTML;

In order to activate the functionality that you want with the open call. Go here: http://www.oreilly.com/openbook/webclient/ch05.html#34288 for more information.

Also, you are not using CGI correctly. The CGI module is object oriented and so you must invoke a new object with:

use CGI;
$cgi_object = new CGI;

Then you can make queries to the object:

print $cgi_object=>foo() # or one of the real calls.

You can also call individual functions:

CGI::somefunct();

WizardWorkz
01-28-2004, 06:31 PM
Hey, Thanks...

I actually posted my initial question 3 years ago (In "Programmers Years") So as we so often do, I found my answer elsewhere. I found this as an answer for the line of code that seems to work:

print redirect('http://www.dogtrax.net/thanks.html');


without touching any other code as you had stated.

So do you still suggest to make me change the other things you had stated? My old mentor used to tell me to not fix it if it's doing what you want it to do.

Regards,
Virgil

grafman
01-28-2004, 11:58 PM
My call is to use modules that are specifically "tuned" to do what you want them to do.

For instance you can use perl sockets, open port 80 on a host and re implement http or you can use CGI and LWP. They encapsulate all the functionality and more importantly are less prone to failures, and are easier to debug when you need to debug them.

As with anything, there are as many ways of doing things as there are people so who am I to say whats right and wrong. "If it ain't broke use a bigger hammer, no?" lol

Happy coding.

WizardWorkz
07-21-2004, 11:14 AM
I actually came up with this at the end of the script and it works:


######
close (SENDMAIL);


print redirect('http://www.dogtrax.net/index.html');


########

So there you all go!