时间:2021-07-01 10:21:17 帮助过:32人阅读
header("Content-Type:html/text;Charset=utf-8");
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$fh = @fopen("14-6.txt","ab");
fwrite($fh,"姓名:".$name,strlen($name));
fwrite($fh,"email:".$email,strlen($email));
fwrite($fh,"评论:".$comment,strlen($comment));
fclose($fh);
echo 1;
?>
function $(id){
return document.getElementById(id);
}
function addcomment(){
var url = "14-6.php";
var status = document.getElementById("divmsg");
status.value="正在提交》》》";
var param = "name="+$("name").value+"email="+$("email").value+"comment="+$("comment").value;
xmlhttp_request.onreadystatechange = function(){
if(xmlhttp_request.readyState==4 && xmlhttp_request.status == 200){//相应完全显示信息
alert (xmlhttp_request.responseText);
if(xmlhttp_request.responseText == "1"){
status.value = "发表成功!!";
$("name").value="";
$("email").value="";
$("comment").value="";
}else{
status.value = "发表失败!请重新发表!";
}
}
}
xmlhttp_request.open("POST",url,true);
xmlhttp_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//设置头信息
xmlhttp_request.send(param);
}