| Help With Form To Mail Script complete Beginner |
ftwb05

msg:3351386 | 10:26 pm on May 27, 2007 (gmt 0) | Hi! I was hoping someone could tell me what I've done wrong with the following script that has come from my webserver help files. It is a simple "form to e-mail" that I have to use on my Windows Server that doesn't support ASP, just PHP (Pearl?). The script takes a comment and passes it to the right e-mail address, which is great, but I don't know how to get it to then direct the user to my thankyou page. I am a complete novice at this and don't really understand what I'm doing, it's taken me three hours to get to the stage where I'm getting the e-mails I want.... I'm probably just missing something really simple. Many thanks in advance! The script: use OLE; use CGI; $jmail = CreateObject OLE "JMail.SMTPMail"; $form = new CGI; $Recipient=$form->param('email'); $domain = $ENV {'SERVER_NAME'}; $referer = $ENV {'HTTP_REFERER'}; $url = $referer; $url =~ s/^http:\/\///i; $url =~ s/^www\.//i; $domain =~ s/^www\.//i; $Sender = "noreply\@$domain"; $SMTPServer = "smtp.$domain:25"; $Subject=$form->param('page'); $Body=$form->param('body'); $Priority=3; $Header = "Originating-IP", $ENV{'REMOTE_ADDR'}; $jmail->{ServerAddress} = $SMTPServer; $jmail->{Sender} = $Sender; $jmail->{Subject} = $Subject; $jmail->AddRecipient ($Recipient); $jmail->{Body} = $Body; $jmail->{Priority} = $Priority; $jmail->AddHeader ($Header); if ($url =~ m/^$domain/) { $mailmessage = "mail sent"; $jmail->Execute; } else { $mailmessage = "mail was not sent. Incorrect Referer"; } print "Result: $mailmessage Recipient: $Recipient"; print "Sender: $Sender SMTP Server: $SMTPServer"; print "Subject: $Subject Referer: $referer"; print "Domain: $domain url: $url ";
|
IanKelley

msg:3352864 | 8:27 pm on May 29, 2007 (gmt 0) | (Resisting the urge to point out potential exploits in script) :-) This will send the user to your thank you page provide you have not already "printed" anything else to the browser: $thanks = 'http://'.'YourDomain.com/YourThanks.Page'."\n\n"; print "Location: $thanks\n\n";
[Edit]Changed variable so that WW parser wouldn't try to hyperlink the URL, the $thanks var does not actually need all the concatenation[/Edit] [edited by: IanKelley at 8:33 pm (utc) on May 29, 2007]
|
ftwb05

msg:3353877 | 8:28 pm on May 30, 2007 (gmt 0) | Many Thanks Ian!
|
|
|