A Simple AJAX base ‘e-mail to friends’ which sends mail on enter key hit
When you put a e-mail address on the text box and hit enter mail will be sent. (u should use email validation condition not included in this code)
put it in any html file
<script type="text/javascript">
function hiten(e){
if(e.keyCode==13)
{
mfrd();
}
}
function mfrd()
{
str = document.getElementById("emailadd").value;
if (str.length==0)
{
document.getElementById("txtHint").innerHTML="email add nai";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","/send.php?m="+str+"&u=link/to/share/via_mail",true);
xmlhttp.send();
}
</script>
<p style="padding:57px 0 10px 0; margin:0; height:auto;">EMAIL FRIEND
<input id="emailadd" onkeypress="hiten(event);" size="10" type="text" />
<p id="txtHint"> </p>
</p>
send.php file:
<?php
$mail_to = $_GET['m'];
$mail_link=$_GET['u'];
$mail_sub = 'share by friends';
$mail_msg = "Your Friends Send this to you
".$mail_link."
AAJ IT TEAM";
$mail_head = 'From: info@example.com' . "\r\n" .
'Reply-To: info@example.com' . "\r\n" .
'X-Mailer: emailed by example.com';
echo "E-mail Sent";
mail($mail_to,$mail_sub,$mail_msg,$mail_head);
mail('admin@example.com','E-mail to friends copy',$mail_msg,$mail_head);
?>
Pingback: http://www.ahoist.net/best-sport-fishing-sailboats/