smurguly
06-15-2003, 08:54 AM
I cut and pasted the instructions from an ebook but I don't some of the instructions.
First, how and where do I create a file called tellafriend.cgi?
Second, it says make sure the 2 lines point to the correct locations on your server. How do you know this?
Third, it says, upload the file to your /cgi-bin/ directory on your server and change the permissions to 755. Well, how do you do that?
Anyone that is kind enough to answer, please give me baby steps.
Thanks a bunch :)
This simple script can be installed quickly on your site, and then you just link to it from every page telling your visitors to: "Tell A Friend About Us!"
To install it, simply create a file called tellafriend.cgi, then copy everything from the box below and paste it into your tellafriend.cgi file that you've created.
Make sure the following two lines point to the correct locations on your server:
#!/usr/bin/perl
$mailprog = '/usr/sbin/sendmail';
Then just upload the file to your /cgi-bin/ directory on your server and change the permissions to 755 and you are set.
You can click here to see what it will look like and how it works. Go ahead and fill in your email address and have it send to you so you can see the emails that will be sent. (While you're at it, why not send to a few friends to recommend Website Traffic System...)
Unique Feature! - The script will send the URL of the page that your visitors clicked from in the email that is sent. Meaning, whatever page of your website they are on when they click the link to Tell A Friend, is the page they will get in the email.
This enables you to offer a Tell your friends about this article feature so they can recommend articles, or other places on your site. Very powerful!
If you would rather they always be sent to your home page, just change this line:
$referer = $ENV{'HTTP_REFERER'};
to:
$referer = 'http://www.yourwebsite.com';
________________
#!/usr/bin/perl
$mailprog = '/usr/sbin/sendmail';
$referer = $ENV{'HTTP_REFERER'};
&parse_form;
&return_html;
&send_mail;
exit;
sub parse_form {
if ($ENV{REQUEST_METHOD} =~ 'GET') {
&print_form;
exit;
}
else {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
if ($FORM{'recipient'} eq "") {
&error;
exit;
}
}
}
sub return_html {
print "Content-type: text/html\n\n";
print "<html>\n <head>\n";
print "<title>Your message was sent!</title>\n\n";
print "<body><center><font face=Verdana size=2>Your message has been sent to $FORM{'recipient'}.<p>\n";
print "<b>Thank you for recommending our site!</b><p>\n\n";
print "Click <a href=$FORM{'url'}>here</a> to return to the page you were viewing.</center></body></html>\n";
}
sub send_mail {
open(MAIL,"|$mailprog -t");
print MAIL "To: $FORM{'recipient'}\n";
print MAIL "From: $FORM{'email'} ($FORM{'name'})\n";
print MAIL "Subject: Check out this site!\n\n";
print MAIL "This email was sent to you by your friend $FORM{'name'}.\n";
print MAIL "---------------------------------------------------------------------------\n\n";
print MAIL "Link to view:\n";
print MAIL "$FORM{'url'}\n\n";
print MAIL "Comments:\n";
print MAIL "$FORM{'comments'}\n\n";
print MAIL "---------------------------------------------------------------------------\n\n";
close (MAIL);
}
sub print_form {
print "Content-type: text/html\n\n";
print "<html>\n <head>\n";
print "</head>\n";
print "<body bgcolor=#FFFFFF>\n\n";
print "<center><br><br><b><font face=Verdana size=2>Use this page to tell your friends about our site.</b></font>\n\n";
print "<form method=post action=/cgi-bin/tellafriend.cgi>\n\n";
print "<table border=0 width=500>\n\n";
print "<tr><td align=right><font face=verdana size=2>Your Name:</td>\n\n";
print "<td><input name=name size=40 type=text align=center></td></tr>\n\n";
print "<tr><td align=right><font face=verdana size=2>Friend's e-mail:</td>\n\n";
print "<td><input name=recipient size=40 type=text align=center></td></tr>\n\n";
print "<tr><td align=right><font face=verdana size=2>Note to your friend:</td>\n";
print "<td><textarea name=comments rows=5 cols=34
wrap=physical></textarea></td></tr></table><p>\n\n";
print "<p align=center><input type=submit value=Send><br><br><font face=Verdana size=1><b>Note: </b>\n";
print "This form is to allow you to tell your friends about our site. We do not store any of the above information.</p>\n\n";
print "<input type=hidden name=url value=$referer></font></form></td></tr></table>\n";
print "</font></center></body></html>\n";
}
sub error {
print "Content-type: text/html\n\n";
print "<font face=Verdana size=2>You forgot to enter your friends email. Please go back and enter one.</font>\n";
}
First, how and where do I create a file called tellafriend.cgi?
Second, it says make sure the 2 lines point to the correct locations on your server. How do you know this?
Third, it says, upload the file to your /cgi-bin/ directory on your server and change the permissions to 755. Well, how do you do that?
Anyone that is kind enough to answer, please give me baby steps.
Thanks a bunch :)
This simple script can be installed quickly on your site, and then you just link to it from every page telling your visitors to: "Tell A Friend About Us!"
To install it, simply create a file called tellafriend.cgi, then copy everything from the box below and paste it into your tellafriend.cgi file that you've created.
Make sure the following two lines point to the correct locations on your server:
#!/usr/bin/perl
$mailprog = '/usr/sbin/sendmail';
Then just upload the file to your /cgi-bin/ directory on your server and change the permissions to 755 and you are set.
You can click here to see what it will look like and how it works. Go ahead and fill in your email address and have it send to you so you can see the emails that will be sent. (While you're at it, why not send to a few friends to recommend Website Traffic System...)
Unique Feature! - The script will send the URL of the page that your visitors clicked from in the email that is sent. Meaning, whatever page of your website they are on when they click the link to Tell A Friend, is the page they will get in the email.
This enables you to offer a Tell your friends about this article feature so they can recommend articles, or other places on your site. Very powerful!
If you would rather they always be sent to your home page, just change this line:
$referer = $ENV{'HTTP_REFERER'};
to:
$referer = 'http://www.yourwebsite.com';
________________
#!/usr/bin/perl
$mailprog = '/usr/sbin/sendmail';
$referer = $ENV{'HTTP_REFERER'};
&parse_form;
&return_html;
&send_mail;
exit;
sub parse_form {
if ($ENV{REQUEST_METHOD} =~ 'GET') {
&print_form;
exit;
}
else {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
if ($FORM{'recipient'} eq "") {
&error;
exit;
}
}
}
sub return_html {
print "Content-type: text/html\n\n";
print "<html>\n <head>\n";
print "<title>Your message was sent!</title>\n\n";
print "<body><center><font face=Verdana size=2>Your message has been sent to $FORM{'recipient'}.<p>\n";
print "<b>Thank you for recommending our site!</b><p>\n\n";
print "Click <a href=$FORM{'url'}>here</a> to return to the page you were viewing.</center></body></html>\n";
}
sub send_mail {
open(MAIL,"|$mailprog -t");
print MAIL "To: $FORM{'recipient'}\n";
print MAIL "From: $FORM{'email'} ($FORM{'name'})\n";
print MAIL "Subject: Check out this site!\n\n";
print MAIL "This email was sent to you by your friend $FORM{'name'}.\n";
print MAIL "---------------------------------------------------------------------------\n\n";
print MAIL "Link to view:\n";
print MAIL "$FORM{'url'}\n\n";
print MAIL "Comments:\n";
print MAIL "$FORM{'comments'}\n\n";
print MAIL "---------------------------------------------------------------------------\n\n";
close (MAIL);
}
sub print_form {
print "Content-type: text/html\n\n";
print "<html>\n <head>\n";
print "</head>\n";
print "<body bgcolor=#FFFFFF>\n\n";
print "<center><br><br><b><font face=Verdana size=2>Use this page to tell your friends about our site.</b></font>\n\n";
print "<form method=post action=/cgi-bin/tellafriend.cgi>\n\n";
print "<table border=0 width=500>\n\n";
print "<tr><td align=right><font face=verdana size=2>Your Name:</td>\n\n";
print "<td><input name=name size=40 type=text align=center></td></tr>\n\n";
print "<tr><td align=right><font face=verdana size=2>Friend's e-mail:</td>\n\n";
print "<td><input name=recipient size=40 type=text align=center></td></tr>\n\n";
print "<tr><td align=right><font face=verdana size=2>Note to your friend:</td>\n";
print "<td><textarea name=comments rows=5 cols=34
wrap=physical></textarea></td></tr></table><p>\n\n";
print "<p align=center><input type=submit value=Send><br><br><font face=Verdana size=1><b>Note: </b>\n";
print "This form is to allow you to tell your friends about our site. We do not store any of the above information.</p>\n\n";
print "<input type=hidden name=url value=$referer></font></form></td></tr></table>\n";
print "</font></center></body></html>\n";
}
sub error {
print "Content-type: text/html\n\n";
print "<font face=Verdana size=2>You forgot to enter your friends email. Please go back and enter one.</font>\n";
}