|
Posted by Sean on 03/19/07 12:17
"Steve" <cdriver24@comcast.net> wrote in message
news:bsudnQL9AP-_-GDYnZ2dnUVZ_u6rnZ2d@comcast.com...
> Hi I need some help in creating php code for sending an email to a
> friend about a particular page on a website. I want the code to send the
> url for what ever specific page the client is on and wants their friend to
> see. Is that possible with php coding?
>
>
> Thanks Steve
>
Yes.
I am sure you can put the following on a HTML page, where you want to put
the button...
<script language="Javascript">
document.write "<FORM action='email.php' method='post'>";
document.write "<INPUT name='url' type='hidden' value='" + location.href +
"'>";
document.write "<INPUT name='email' type='text' value=''>";
document.write "<INPUT name='submit' type='submit' value='Send Link'>";
document.write "</FORM>";
</script>
Then create the"email.php" page, for which it wouldn't be a lot different
from:
<?php
$email = $_POST['email'];
$url = $_POST['url'];
$headers = "From: info@mycompany.com \r\n";
$headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
$headers.= "MIME-Version: 1.0 ";
$body = "Check out this website\r\n";
$body.= $url;
$body = "Thanks\r\n";
$body = "From ...\r\n";
mail($email, "Check out this page", $body, $headers);
?>
<!-- Add some HTML here so that they know it's been emailed and perhaps a
link back to the previous page -->
GOOGLE for PHP MAIL for more information on the email functions in PHP
Hope that helps.
Navigation:
[Reply to this message]
|