2011-06-22 197 views
0

因此,多虧了response to my previous question,我試着讓代碼通過電子郵件發送給我,如果代碼位於另一個站點上。Ajax調用PHP函數

這裏是我的javascript其目的是爲潛在的小偷代碼採取與他們自己的網站:

<script type="text/javascript"> 
var mypostrequest=new ajaxRequest() 
mypostrequest.onreadystatechange=function(){ 
if (mypostrequest.readyState==4){ 
    if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){ 
    document.getElementById("result").innerHTML=mypostrequest.responseText 
    } 
    else{ 
    alert("An error has occured making the request") 
    } 
} 
} 

var url = document.domain; 
var joel="www.joelhoskin.net76.net"; 
if (url!=joel) 
{ 
mypostrequest.open("POST", "http://www.joelhoskin.net76.net/email.php", true) 
mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded") 
mypostrequest.send(url) 
} 
</script> 

,這裏是在joelhoskin.net76.net/email.php的PHP

`<?php 
     $url=$_POST['url']; 
     if(isset($url)) 
      { 
      $to = '[email protected]'; 
      $from = '[email protected]'; 
      $subject = 'Stolen Page'; 
      $content = $url."Site Stolen"; 
      $result = mail($to,$subject,$content,'From: '.$from."\r\n"); 
       die($result); 
       } 

     ?>`  

像它不是我發送電子郵件它應該

回答

1
mypostrequest.send(url) 

你做發送數據,但沒有鑰匙。這樣做:

mypostrequest.send('url='+url) 

它應該使它工作。

+0

謝謝我回頭看看我使用的參考,事實證明,我確實錯過了那一點 但是,它仍然沒有給我發電子郵件 – Joel