2- print this topic script.
<a href="javascript:window.print()">Print this page</a>
3- send this topic to a friend script
When I needed to do this, I basically created a PHP page called 'send2friend.php' which relied on a variable being carried over, in this case the page name that I'm on. As i was only doing this for 3 pages, I thought it easier to manually code the html to do so, I then used open.window to open a popup with that page and the url passed.
<script type="text/javascript">
// Window Open
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
</script>
<a href="#" onClick="MM_openBrWindow('send2friend.php?page=vps-basic','Send2friend','resizable=yes,width=410,height=300')">Send to a friend </a>
My send2friend page looks like
[php]
<?
// Send to friend script.. This page will send the given link to a friend
// Carl Pickering - Line3 Internet
// Quick and dirty hack to get a full URL.
$tPAGE = $_GET['page'];
$PAGE = "http://www.domain.co.uk/" . $tPAGE . ".php";
// Send the details
if($_POST['action']=='send') {
// define some variables first
$send_to = $_POST['f_email'];
$y_person = $_POST['y_name'];
$y_email = $_POST['y_email'];
$f_name = $_POST['f_name'];
$subject = "Interesting Link from - $y_person";
$thank_you ="We have passed on the page to - $f_name";
// Build the message
$message = "Hi $f_name ,\n\n";
$message .= "I found this page, and thought it might be of interest\n";
$message .= "Link: $PAGE\n";
$message .= "Let me know what you think, $y_person\n\n\n";
$message .= "You were sent this email because $y_person <$y_email> thought it might be of interest. We do not keep your information";
$mailheaders = "From: $y_person <$y_email> \n";
$mailheaders .= "Reply-To: $y_person <$y_email>\n\n";
// Simple but basic.. Now send the email
mail($send_to, $subject, $message, $mailheaders);
print(" <script language=\"Javascript\"> alert('$thank_you'); </script> ");
print(" <script language=\"Javascript\">window.close();</script> ");
}
?>
[/php]
My form code (change as needed)
[php]
<form action="<? $_SERVER['PHP_SELF']; ?>" method="post" name="send2friend" id="send2friend">
<table width="400" border="0" align="center" cellpadding="0" bgcolor="#FFFFFF">
<tr bgcolor="#FFFFFF">
<td colspan="2"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2"> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2">Found something that a friend might be interested in? Fill in the information below to notify them of what you found. </td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2"> </td>
</tr>
<tr>
<td width="30%">Friends Name:</td>
<td width="50%"><input name="f_name" type="text" id="f_name" size="25" maxlength="60"></td>
</tr>
<tr>
<td>Friends Email:</td>
<td><input name="f_email" type="text" id="f_email" size="25" maxlength="64"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Your Name: </td>
<td><input name="y_name" type="text" id="y_name" size="25" maxlength="60"></td>
</tr>
<tr>
<td>Your Email:</td>
<td><input name="y_email" type="text" id="y_email" size="25" maxlength="64"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Page to be sent: </td>
<td><? echo "$PAGE"; ?></td>
</tr>
<tr>
<td><input name="action" type="hidden" id="action" value="send"></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><a href="javascript
:document.send2friend.reset();">Reset</a><img src="images/read_1.gif" alt="" style="margin:0px 5px 0px 30px;"><a href="javascript
:document.send2friend.submit();">Submit</a></td>
</tr>
</table>
</form>
[/php]