我在我的网站更新的邮件系统,我想不通,为什么下面的代码块是不工作: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