我在我的網站更新的郵件系統,我想不通,爲什麼下面的代碼塊是不工作:AJAX/PHP問題
function sendReply(id,from,to)
{
var subject = document.getElementById("subject").innerHTML;
var body = document.getElementById("body").innerHTML;
var xmlhttp;
if (id.length==0) {
document.getElementById("userMessagingBackground").innerHTML = "";
return;
}
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "sendOutReply.php?from=" + from + "&to=" + to + "&subject=" + subject + "&body=" + body, true);
xmlhttp.send();
document.getElementById("userMessagingBackground").style.display = "none";
}
所以......呃...這有什麼不對嗎?如果不是......這是PHP部分:
<?php
$to = $_GET['to'];
$dbc = mysqli_connect(Database Connection Stuff);
$username = $_GET['user'];
if (!empty($_GET['body'])) {
$sub = $_GET['subject'];
$body = "Sent by $username:\n---\n"
. $_GET['body'] . "\n\n------------------------\n\n"
. $receivedMsg;
$STM = "INSERT INTO messagingTable
(new, sender, receiver, subject, message, sentDate)
VALUES ('1', '$username', '$to', 'RE: $subject', '$body', NOW())";
$sendMessage = mysqli_query($dbc, $STM);
$findReceiver = "SELECT * FROM usersTable WHERE username = '$to'";
$getTo = mysqli_query($dbc,$findReceiver);
$toRow = mysqli_fetch_array($getTo);
if ($toRow['emailOnPm'] == 1) {
mail($toRow['email'],$sub,$body, "From: AllThemGames.com");
}
}
?>
當你說它不工作時,你在看什麼? –
你在做什麼回調? – tafoo85
你在你的網站上使用什麼版本的PHP? – DrewCo