所以,在之前的一些建议之后,我想创建一个电子邮件表单,在您提交有效的电子邮件后,注册框会消失,并显示一条新消息,说明“感谢您注册”或其他内容。我得到了验证。而且我的process.php有效。此外,#message会被隐藏,但页面会在之后重定向并显示在地址栏中:www.myurl.com/?address = wartteveriinputed @ whatever.com
以下是关于发布的jquery代码:
function stateChanged3 () {
}
function GetXmlHttpObject () {
var requestObj = null;
if (window.XMLHttpRequest)
requestObj = new XMLHttpRequest();
else if (window.ActiveXObject)
requestObj = new ActiveXObject("Microsoft.XMLHTTP");
return requestObj;
}
requestObj3 = GetXmlHttpObject();
var url = "mlml/process.php?address=" + emailaddressVal;
requestObj3.open("POST", url, true);
requestObj3.onreadystatechange = stateChanged3;
requestObj3.send(null);
$('#message').toggle();
我的php代码非常简单,它是一个经过修改的开源邮件程序如下:
$email = $_REQUEST["address"];
$key = md5(time());
$req_time = time();
$query = "SELECT * FROM `mailinglist_subscribers` WHERE `address` = '$email'";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$num_rows = mysql_num_rows($result);
if ($num_rows != 1) {
$query = "INSERT INTO mailinglist_subscribers VALUES ('$email', '$key', '1', '$req_time', '0')";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
}
答案 0 :(得分:0)