Forum Moderators: coopster

Message Too Old, No Replies

"e-mail this article to a friend" ?

can't quite find this functionality

         

mbatta

1:44 am on Nov 18, 2004 (gmt 0)

10+ Year Member



I've searched some of the usual spots, but cant find a script or something that will send the current url (I dont have to pre-define) to the e-mail a user inputs? Any input?

dreamcatcher

9:31 am on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried hotscripts.com? Have you thought of having a go yourself? This would be a fairly easy thing to code.

mbatta

2:15 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



saw one on hotscripts where you pre-define the url. Im a total newbie and outside of some VB/VBscript have very little experience with this side of development (please hold your laughter in). Any help or guidance would be appreciated.

ukgimp

3:06 pm on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



here you go mate, you will need to play with it. I hope to christ i have not left something personal in there lol. Watch the smily faces, they will nause the code up

Just put a link to it from any page and it takes that from the referer and stuffs it in

<?php
$page_title = "Send To Friend";

$error_variables = false;
if ($_SERVER['REQUEST_METHOD'] == "POST"){

$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
if (isset($_POST['ref'])) {
$ref = $_POST['ref'];
}
$value = $email;
$pattern = "/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/";
if(!preg_match($pattern, $value))
{
$error_variables = true;
$errors["email"] = true;
}

if (!$error_variables){

$message_full = "$message\n";

$my_email = "$email";
mail("$my_email", $subject, $message_full, "From: feedback@url.com");

print "<p>Your mail has been sent</p>";

}
else
{

?>

<p>There is a problem with the data you have used. Please check and send again.</p>

<form method="post" action="send_to_friend.php" class="formadd">
<table width="100%">
<tr>

<td width="21%"><b>The link you are sending</b></td>

<td width="2%">&nbsp;</td>

<td width="77%">
<?php
if (strlen($ref) >50) {
$refLen = strlen($ref);
for ($i = 0, $i < $refLen; $i = $i + 50;) {
echo substr($ref, $i, $i + 50) . '<br />';
}
} else {
print "$ref";
}
?>
</td>
</tr>
<tr>
<td width="21%"><b>Your Friends Email</b></td>
<td width="2%">&nbsp;</td>
<td width="77%">
<input type="text" name="email" value="<?php echo $email?>" class="term" size="50">
<?php
//show bold for error
if ($errors["email"]){
print '<b><font color="#FF0000">Have you missed the @ symbol?</font></b>';
}

?>

</td>
</tr>
<tr>
<td width="21%"><b>Subject</b></td>
<td width="2%">&nbsp;</td>
<td width="77%">
<input type="text" name="subject" value="<?php echo $subject?>" class="term" size="50">
<?php
//show bold for error
if (!isset($errors['subject']) ¦¦ $errors["subject"]){
print "<b><font color=\"#FF0000\">Please Type a Subject</font></b>";
}

?>

</td>
</tr>

<tr>
<td width="21%" align="left" valign="top"><b>Message</b></td>
<td width="2%">&nbsp;</td>
<td width="77%">
<textarea name="message" cols="50" rows="10"><?php echo $message?></textarea>
</td>
</tr>
<tr>
<td width="21%">&nbsp;</td>
<td width="2%">&nbsp;</td>
<td width="77%">&nbsp; </td>
</tr>
</table>
<p>
<input type="submit" value="Send Email" class="button">
</p>
</form>
<?php

};

}

else
{

?>

<form method="post" action="send_to_friend.php">
<div id="search">
<table width="100%">
<tr>
<td width="21%"><b>The link you are sending</b></td>
<td width="2%">&nbsp; </td>
<td width="77%">
<?php
$ref= $_SERVER["HTTP_REFERER"];
if (strlen($ref) >50) {
$refLen = strlen($ref);
for ($i = 0, $i < $refLen; $i = $i;) {
echo substr($ref, $i, $i + 50) . '<br />';
$i = $i + 50;
}
} else {
print "$ref";
}
?>
</td>
</tr>
<tr>
<td width="21%"><b>Your Friends Email</b></td>
<td width="2%">&nbsp;</td>
<td width="77%">
<input type="text" name="email" value="" class="term" size="50">
</td>
</tr>
<tr>
<td width="21%"><b>Subject</b></td>
<td width="2%">&nbsp;</td>
<td width="77%">
<input type="text" name="subject" value="" class="term" size="50">
</td>
</tr>
<tr>
<td width="21%" align="left" valign="top"><b>Message</b></td>
<td width="2%">&nbsp;</td>
<td width="77%">
<textarea name="message" cols="50" rows="10">Hello, I found this webpage and thought that it would interest you.
<?php
print "$ref";
?>

Thanks
</textarea>
</td>
</tr>
<tr>
<td width="21%">&nbsp;</td>
<td width="2%">&nbsp;</td>
<td width="77%">
<input type="hidden" name="ref" value="<?php echo $ref;?>">
</td>
</tr>
</table>
<p>
<input type="submit" value="Send Email" class="button">
</p>
</div>
</form>
<?php

}
?>

jamie

3:30 pm on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



if you didn't want to rely on HTTP_REFERER, which is often blocked by personal firewalls, you could link to the friend.php script with a single parameter giving the page name you are on, e.g.

friend.php?referer=$_SERVER['REQUEST_URI']

then in the script you would change
$ref=$_SERVER['HTTP_REFERER'] for
$ref=$_GET['referer']

not sure if that helps or hurts ;-)