Current location: Hot Scripts Forums » General Community » Script Requests » Forward a Web Page to a Friend by Email


Forward a Web Page to a Friend by Email

Reply
  #1 (permalink)  
Old 08-25-07, 04:36 PM
cgjustice cgjustice is offline
New Member
 
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Forward a Web Page to a Friend by Email

Hi,

I'm looking for a script that will allow a web page viewer to forward that page's URL to a friend by email.

Ideally, the user should be able to enter fields on the web page, such as the name of the sender, the name of the receiver, the email address of the receiver, a personal note from the sender ... and then those fields be reflected in the email.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-26-07, 01:08 AM
Boraan's Avatar
Boraan Boraan is offline
Coding Addict
 
Join Date: Jul 2007
Location: Clayton, NC
Posts: 292
Thanks: 0
Thanked 1 Time in 1 Post
Here is the HTML page (simple form).
Code:
<html>
<head>
<title>Email This Page To A Friend</title>
<link rel="StyleSheet" type="text/css" href="url to css file">
</head>

<body bgcolor="#E1E1E1">
<form action="cgi-bin/email.cgi" method="POST">
<table><tr><td>
<b>Tell a friend about this page!</b></td>
</tr></table>

<table>
<tr><td>Friend's First Name: </td><td><input type="text" name="fname"></td></tr>
<tr><td>Your Friend's Email: </td><td><input type="text" name="femail"></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>Your First Name: </td><td><input type="text" name="sname"></td></tr>
<tr><td>Your Email: </td><td><input type="text" name="semail"></td></tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>

</body>
</html>
and here is the cgi.

Code:
#!/usr/bin/perl
print "Content-type:text/html\n\n";

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;
}

if ($FORM{'fname'} eq "") {
&dienice("Please enter your friend's name.");
exit;
}

if ($FORM{'femail'} eq "") {
&dienice("Please enter friend's email address.");
exit;
}

if ($FORM{'sname'} eq "") {
&dienice("Please fill in your email address name.");
exit;
}

if ($FORM{'semail'} eq "") {
&dienice("Please enter your email address.");
exit;
}

print <<EndHead;
<html>
<head>
<title>Message Sent</title>
<link rel="StyleSheet" type="text/css" href="url to css">
</head>

<body bgcolor="#E1E1E1">
EndHead

$mailprog = '/usr/sbin/sendmail';
$recipient = "$FORM{'femail'}";
$from = "$FORM{'semail'}";

open (MAIL, "|$mailprog -t") or &dienice("Can't access $mailprog!\n");
print MAIL "To: $recipient\n";
print MAIL "From: $from\n";
print MAIL "Reply-to: $FORM{'semail'}\n";
print MAIL "Subject: Hey. Check this site out.\n\n";

print MAIL <<EndMAIL;
Hey $FORM{'fname'},

put your default message here. Don't forget to put the url of the page!

$FORM{'sname'}

EndMAIL

close(MAIL);

# now print something to the HTML page, usually thanking the person
# for filling out the form, and giving them a link back to your homepage

print <<EndHTML;
<font size="4"><b>Message Sent</b></font>
<p><a href="../email.html" target="_self">Click here</a> to send this page to another friend.
<br><br>[<a href="http://" onClick="javascript:window.close();">Close this window</a>]</p>



</body>
</html>
EndHTML
exit;

sub dienice {
my($msg) = @_;
print qq(
<html>
<head>
<title>Email this page to a friend</title>
<link rel="StyleSheet" type="text/css" href="url to css file">
</head>
<body bgcolor="#E1E1E1">
<font size="4">Error</font><p>\n);
print qq($msg <a href="http://" onClick="history.go(-1);" target="_self">Go back</a> and try again.\n);
print qq(</body></html>);
exit;
}
I named the html file email.html and placed the email.cgi script in my cgi-bin directory.

cheers!
__________________
Dexter Nelson
Techdex Development & Solutions
========================
Internet Marketing For Programmers | Free Market Research in 15 Minutes or Less
My Software: Hotscripts Softpedia software.techdex.net
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-28-07, 01:24 AM
curbview.com's Avatar
curbview.com curbview.com is offline
Junior Code Guru
 
Join Date: May 2006
Posts: 555
Thanks: 0
Thanked 0 Times in 0 Posts
I would sanitize any user input for hackers are among us. Otherwise, it will get the job done for what the OP wants!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 08-29-07, 08:39 AM
Boraan's Avatar
Boraan Boraan is offline
Coding Addict
 
Join Date: Jul 2007
Location: Clayton, NC
Posts: 292
Thanks: 0
Thanked 1 Time in 1 Post
untainting is always a great idea... here we go... add this to the cgi file for not just untaint, but format the fields..

Code:
# Untaint/Format email strings
if ($FORM{'femail'} !~ /[\w\-]+\@[\w\-]+\.[\w\-]+/) {
	&dienice("You did not enter a valid email address.");
}

if ($FORM{'semail'} !~ /[\w\-]+\@[\w\-]+\.[\w\-]+/) {
	&dienice("You did not enter a valid email address.");
}

# Untaint text strings
if ($FORM{'fname'} !~ /[a-z0-9][A-Z0-9]/) {
	&dienice("Quit trying to hack my system... PHREAK!");
}

if ($FORM{'sname'} !~ /[a-z0-9][A-Z0-9]/) {
	&dienice("Quit trying to hack my system... PHREAK!");
}
You can also add maxlenth="numerical value" to limit how many characters can be entered into the text fields on the html page.
__________________
Dexter Nelson
Techdex Development & Solutions
========================
Internet Marketing For Programmers | Free Market Research in 15 Minutes or Less
My Software: Hotscripts Softpedia software.techdex.net
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nixism | Affordable/Reliable Web Hosting: cPanel, Fantastico, PHP 5, Ruby.. more!! .amaZe General Advertisements 0 06-04-07 09:02 PM
Page Creator + Email provider alexfrance250291 Script Requests 0 03-23-06 07:55 AM
WEB HOSTING - $4.99/MONTH For 1GB HD & 25GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 0 12-10-05 09:13 AM
WEB HOSTING - $4.99/MONTH For 1GB HD & 25GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 0 02-28-05 12:56 AM
Free .ASP 'tell a friend' email form needed, preferably with multiple friend spaces retrocom Script Requests 0 08-23-03 01:44 PM


All times are GMT -5. The time now is 09:40 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.