CarolinaWeb
02-14-2005, 10:21 PM
Hello all,
I have a PHP (send this url to a friend) script that I now have set up in a web site that I'm working on that works perfectly. It uses javascript to get the url variable from the web page and posts it into my php form. However, my client has now decided that they want to use a Windows 2000 server rather than Unix, and the Windows server doesn't support PHP. :(
Presently, the javascript is executed when you click on the link "Email this page". Then a form pops up in a seperate window where you can enter your name, email and the recipients email. The url variable from the javascript is passed into this form.
I don't know very much about writing CGI or Perl, so I really need some help! I am hoping to just use a "tell a friend" CGI script that I found online and modify it to get the page url variable. I want to use the same pop up form for about 40 different pages on this web site, hence the need to be able to get the url variable from these different pages into the form somehow.
Can anyone please tell me what I need to have in the html page, cgi script or my form to capture this variable from each page? Your help would be greatly appreciated!
Here is the cgi script that I want to try to modify. As you can see, it only allows for one set url variable to be entered:
#!/usr/bin/perl
# Tell A Friend Script
# (c) Copyright Wayne Pearsall
# webmaster@e-walks.tk
# All rights Reserved
# PS it would be cool if you leave the credit
# for my script on the thanks page :)
############ This is the mainish.. part of the script it is calling
"et_form; # Dont Take out this line else the script will not
############ include the form email address' :)
# Set the location of your servers Sendmail Program
$SEND_MAIL = "/usr/sbin/sendmail";
# Set The URL of Your Website you wish to promote.
$My_Site_Url = "http://www.micradc.com";
# What Email address do you want the Email to come from?
# 1 = your email address 2 = senders email address
$Whos_Email = "2";
# Subject To Use When Telling A Friend $FORM{who_name} is the persons name.
$Tell_Friend_Subject = "$FORM{who_name}, I Just Found An Interesting Site";
# If you Answered 1 to the last variable, Whats your Email?
# Always put a \ before the @ sign.
$My_Email = "my_name\@my_host.com";
# /////////////////////////////////////////////////////
# And Finally Set The HTML code for the thanks Page.
# |||||||||||||||||||||||||||||||||||||||||||||||||||||
# Include $FORM{who_to} to set the email name of the recepiant
# and $FORM{who_from} to set the name of the sender.
# add $FORM{who_name} to add the recievers r/name
# \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
$Tell_a_Friend_Text=<<__Stop_Of_Email_Message__; # NOTE! DO NOT EDIT THIS LINE AT ALL!
Hi $FORM{who_name} ,
I have just been to an excellent website,
and thought that you too may enjoy visiting.
The URL to the website is:
$My_Site_Url
Thank You
$FORM{who_from}
__Stop_Of_Email_Message__
# NOTE! DO NOT EDIT ABOVE LINE AT ALL! (as in __Stop_ - above that is fine
# /////////////////////////////////////////////////////
# And Finally Set The HTML code for the thanks Page.
# \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
print "Content-type: text/html\n\n";
print <<__End_Of_Thanks_Page__; # NOTE! DO NOT EDIT Above LINE AT ALL!
<HTML>
<HEAD>
<TITLE> Email Sent To Friend </TITLE>
</HEAD>
<BODY>
<H1><CENTER>Thank You!</CENTER></H1>
<H4><CENTER>An Email Has Been Sent To $FORM{who_name} About My Website</CENTER><H4>
<p align="center"><font>Please <A HREF=" $My_Site_Url ">Click Here</A> To Return To My Site</font></p>
<BR>
<BR>
<BR>
<p align="center"><font size="1">Script by <a href="mailto:scripts\@designz.yoll.net?subject=Tell-A-Friend CGI">WPearsall</A>.</font></p>
</BODY>
</HTML>
__End_Of_Thanks_Page__
# NOTE! DO NOT EDIT THIS LINE AT ALL!
###################################################################
# OK - Setup All Done. #
###################################################################
if ($Whos_Email eq "1")
{
$Email_From = $My_Email;
}
if ($Whos_Email eq "2")
{
$Email_From = $FORM{who_from};
}
# End Desision.. Time To Tell The Friend.
open (MAIL, "|$SEND_MAIL -t"); ## Email to the recepiant
print MAIL "To: $FORM{who_to}\n";
print MAIL "From: $Email_From \n";
print MAIL "Subject: $Tell_Friend_Subject \n\n";
print MAIL " $Tell_a_Friend_Text \n";
close(MAIL); ## Finish e-mail to user webmaster
## The Part of the program referred to at the very start
## *remember "et_form; ? Well this reason the email address,
## and recepiants name
sub get_form {
if ($ENV{"REQUEST_METHOD"} eq 'GET') {
$buffer = $ENV{'QUERY_STRING'};
} else {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}
Thanks so much for your time and help!
I have a PHP (send this url to a friend) script that I now have set up in a web site that I'm working on that works perfectly. It uses javascript to get the url variable from the web page and posts it into my php form. However, my client has now decided that they want to use a Windows 2000 server rather than Unix, and the Windows server doesn't support PHP. :(
Presently, the javascript is executed when you click on the link "Email this page". Then a form pops up in a seperate window where you can enter your name, email and the recipients email. The url variable from the javascript is passed into this form.
I don't know very much about writing CGI or Perl, so I really need some help! I am hoping to just use a "tell a friend" CGI script that I found online and modify it to get the page url variable. I want to use the same pop up form for about 40 different pages on this web site, hence the need to be able to get the url variable from these different pages into the form somehow.
Can anyone please tell me what I need to have in the html page, cgi script or my form to capture this variable from each page? Your help would be greatly appreciated!
Here is the cgi script that I want to try to modify. As you can see, it only allows for one set url variable to be entered:
#!/usr/bin/perl
# Tell A Friend Script
# (c) Copyright Wayne Pearsall
# webmaster@e-walks.tk
# All rights Reserved
# PS it would be cool if you leave the credit
# for my script on the thanks page :)
############ This is the mainish.. part of the script it is calling
"et_form; # Dont Take out this line else the script will not
############ include the form email address' :)
# Set the location of your servers Sendmail Program
$SEND_MAIL = "/usr/sbin/sendmail";
# Set The URL of Your Website you wish to promote.
$My_Site_Url = "http://www.micradc.com";
# What Email address do you want the Email to come from?
# 1 = your email address 2 = senders email address
$Whos_Email = "2";
# Subject To Use When Telling A Friend $FORM{who_name} is the persons name.
$Tell_Friend_Subject = "$FORM{who_name}, I Just Found An Interesting Site";
# If you Answered 1 to the last variable, Whats your Email?
# Always put a \ before the @ sign.
$My_Email = "my_name\@my_host.com";
# /////////////////////////////////////////////////////
# And Finally Set The HTML code for the thanks Page.
# |||||||||||||||||||||||||||||||||||||||||||||||||||||
# Include $FORM{who_to} to set the email name of the recepiant
# and $FORM{who_from} to set the name of the sender.
# add $FORM{who_name} to add the recievers r/name
# \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
$Tell_a_Friend_Text=<<__Stop_Of_Email_Message__; # NOTE! DO NOT EDIT THIS LINE AT ALL!
Hi $FORM{who_name} ,
I have just been to an excellent website,
and thought that you too may enjoy visiting.
The URL to the website is:
$My_Site_Url
Thank You
$FORM{who_from}
__Stop_Of_Email_Message__
# NOTE! DO NOT EDIT ABOVE LINE AT ALL! (as in __Stop_ - above that is fine
# /////////////////////////////////////////////////////
# And Finally Set The HTML code for the thanks Page.
# \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
print "Content-type: text/html\n\n";
print <<__End_Of_Thanks_Page__; # NOTE! DO NOT EDIT Above LINE AT ALL!
<HTML>
<HEAD>
<TITLE> Email Sent To Friend </TITLE>
</HEAD>
<BODY>
<H1><CENTER>Thank You!</CENTER></H1>
<H4><CENTER>An Email Has Been Sent To $FORM{who_name} About My Website</CENTER><H4>
<p align="center"><font>Please <A HREF=" $My_Site_Url ">Click Here</A> To Return To My Site</font></p>
<BR>
<BR>
<BR>
<p align="center"><font size="1">Script by <a href="mailto:scripts\@designz.yoll.net?subject=Tell-A-Friend CGI">WPearsall</A>.</font></p>
</BODY>
</HTML>
__End_Of_Thanks_Page__
# NOTE! DO NOT EDIT THIS LINE AT ALL!
###################################################################
# OK - Setup All Done. #
###################################################################
if ($Whos_Email eq "1")
{
$Email_From = $My_Email;
}
if ($Whos_Email eq "2")
{
$Email_From = $FORM{who_from};
}
# End Desision.. Time To Tell The Friend.
open (MAIL, "|$SEND_MAIL -t"); ## Email to the recepiant
print MAIL "To: $FORM{who_to}\n";
print MAIL "From: $Email_From \n";
print MAIL "Subject: $Tell_Friend_Subject \n\n";
print MAIL " $Tell_a_Friend_Text \n";
close(MAIL); ## Finish e-mail to user webmaster
## The Part of the program referred to at the very start
## *remember "et_form; ? Well this reason the email address,
## and recepiants name
sub get_form {
if ($ENV{"REQUEST_METHOD"} eq 'GET') {
$buffer = $ENV{'QUERY_STRING'};
} else {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}
Thanks so much for your time and help!