08-29-2008, 12:22 PM
| THREAD STARTER
#1 (permalink)
|
| New Member Join Date: Aug 2008
Posts: 12
| [Resolved] How to add send IP to a AJAX mailer Im having problems getting the IP of the sender to be sent with the email. I'll post the 2 main pages. index.php - i tried to add a input type hidden and named it IP and everything, but i cant figure out to make it send with the email Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Contact Me</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="js/functionAddEvent.js"></script>
<script type="text/javascript" src="js/contact.js"></script>
<script type="text/javascript" src="js/xmlHttp.js"></script>
<style type='text/css' media='screen,projection'>
<!--
body { margin:20px auto;width:600px;padding:20px;border:1px solid #ccc;background:#fff;font-family:georgia,times,serif; }
fieldset { border:0;margin:0;padding:0; }
label { display:block; }
input.text,textarea { width:300px;font:12px/12px 'courier new',courier,monospace;color:#333;padding:3px;margin:1px 0;border:1px solid #ccc; }
input.submit { padding:2px 5px;font:bold 12px/12px verdana,arial,sans-serif; }
-->
</style>
</head>
<body>
<h2>Contact Me</h2>
<div id="contactFormArea">
<form action="scripts/contact.php" method="post" id="cForm">
<fieldset>
<label for="posName">Name:</label>
<input class="text" type="text" size="25" name="posName" id="posName" />
<label for="posEmail">Email:</label>
<input class="text" type="text" size="25" name="posEmail" id="posEmail" />
<label for="posRegard">Subject:</label>
<input class="text" type="text" size="25" name="posRegard" id="posRegard" />
<label for="posText">Message:</label>
<textarea cols="50" rows="5" name="posText" id="posText"></textarea>
<label for="selfCC">
<input type="checkbox" name="selfCC" id="selfCC" value="send" /> Send CC to self
</label>
<label>
<input class="submit" type="submit" name="sendContactEmail" id="sendContactEmail" value=" Send Email " />
</label>
</fieldset>
</form>
<p id="loadBar" style="display:none;">
<strong>Sending Email via AJAX. Hold on just a sec…</strong><br />
<img src="img/processing.gif" alt="Loading..." title="Sending Email" />
</p>
<p id="emailSuccess" style="display:none;">
<strong style="color:green;">Success! Your Email has been sent.</strong>
</p>
</div>
</body>
</html> this is contact.php????: NamePros.com http://www.namepros.com/programming/508806-how-add-send-ip-ajax-mailer.html????: NamePros.com http://www.namepros.com/showthread.php?t=508806 Code: <?php
// Change the 4 variables below
$yourName = 'xxxxxxx';
$yourEmail = 'xxxxxxxx@gmail.com';
$yourSubject = 'xxxxxxxxxxxx';
$referringPage = 'xxxxxxxxxxxxxxxx/contact/index.php';
// No need to edit below unless you really want to. It's using a simple php mail() function. Use your own if you want
function cleanPosUrl ($str) {
return stripslashes($str);
}
if ( isset($_POST['sendContactEmail']) )
{
$to = $yourEmail;
$subject = $yourSubject.': '.$_POST['posRegard'];
$message = cleanPosUrl($_POST['posText']);
$headers = "From: ".cleanPosUrl($_POST['posName'])." <".$_POST['posEmail'].">\r\n";
$headers .= 'To: '.$yourName.' <'.$yourEmail.'>'."\r\n";
$mailit = mail($to,$subject,$message,$headers);
if ( @$mailit ) {
header('Location: '.$referringPage.'?success=true');
}
else {
header('Location: '.$referringPage.'?error=true');
}
}
?> and finally this is xmlHttpRequest.php Code: <?php
// change the 4 variables below
$yourName = 'xxxxxxx';
$yourEmail = 'xxxxxxxx@gmail.com';
$yourSubject = 'xxxxxxxxxxxx';
$referringPage = 'xxxxxxxxxxxxxxxx/contact/index.php';
// no need to change the rest unless you want to. You could add more error checking but I'm gonna do that later in the official release
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
echo '<resultset>';
function cleanPosUrl ($str) {
$nStr = $str;
$nStr = str_replace("**am**","&",$nStr);
$nStr = str_replace("**pl**","+",$nStr);
$nStr = str_replace("**eq**","=",$nStr);
return stripslashes($nStr);
}
if ( $_GET['contact'] == true && $_GET['xml'] == true && isset($_POST['posText']) ) {
$to = $yourName;
$subject = 'Trade Edmonton: '.cleanPosUrl($_POST['posRegard']);
$message = cleanPosUrl($_POST['posText']);
$headers = "From: ".cleanPosUrl($_POST['posName'])." <".cleanPosUrl($_POST['posEmail']).">\r\n";
$headers .= 'To: '.$yourName.' <'.$yourEmail.'>'."\r\n";
$mailit = mail($to,$subject,$message,$headers);
if ( @$mailit )
{ $posStatus = 'OK'; $posConfirmation = 'Success! Your Email has been sent.'; }
else
{ $posStatus = 'NOTOK'; $posConfirmation = 'Your Email could not be sent. Please try again'; }
if ( $_POST['selfCC'] == 'send' )
{
$ccEmail = cleanPosUrl($_POST['posEmail']);
@mail($ccEmail,$subject,$message,"From: Yourself <".$ccEmail.">\r\nTo: Yourself");
}
echo '
<status>'.$posStatus.'</status>
<confirmation>'.$posConfirmation.'</confirmation>
<regarding>'.cleanPosUrl($_POST['posRegard']).'</regarding>
';
}
echo' </resultset>';
?>
Last edited by Exhale; 08-31-2008 at 10:45 PM.
Reason: added resolved
|
| |