Jump to content

Email Posting Twice


sKunKbad

Recommended Posts

I'd like to be able to use this javascript, because then the user doesn't have to see the lag of the mail processing script, but when I use it, the email gets sent twice for some reason. If I post to the mail processing script directly, then it works right. Actually, it's only Opera and IE6/IE7 that had the problem with the double posts. Firefox and Safari are OK. Any ideas?

 

<script type='text/javascript'>
	<!--
	var url = 'http://www.mysite.com/mailproc.php';
	var params = 'realname=<?php echo $realname; ?>&email=<?php echo $email; ?>&mesg=<?php echo $mesg; ?>&recipients=rbg';
	function createRequestObject() {
		var req;
		if(window.XMLHttpRequest){
			req = new XMLHttpRequest();
		} else if(window.ActiveXObject) {
			req = new ActiveXObject('Microsoft.XMLHTTP');
		} else {
			alert('There was an error while submitting your message. Please try a different contact method.');
		}
		return req;
	}
	var http = createRequestObject();
	http.open('POST', url, true);
	http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	http.setRequestHeader('Content-length', params.length);
	http.setRequestHeader('Connection', 'close');
	http.send(params);
	//-->
</script>

Link to comment
https://forums.phpfreaks.com/topic/86263-email-posting-twice/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.