似乎看起来有两种方法,一种ajax,一种提交给iframe
iframe方法:
http://www.websbook.com/javascript/ymbsx_tjbd_4182.html
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form name="form1" method="post" action="abc_update" target="upload">
<p>
<input type="text" name="textfield">
</p>
<p>
<input type="text" name="textfield2">
</p>
<p>
<input type="submit" name="Submit" value="提交">
</p>
</form>
<iframe src="abc_update.asp" name=update height=0 width="0"></iframe>
</body>
</html>
ajax 方法:
http://www.offid.cn/i/564/note/98857.html
前台文件:
<script type="text/javascript" src="js/jquery.js" mce_src="js/jquery.js"></script>
<input name="writer" id="writer" type="text" value="" />
<input name="pass" id="pass" type="password" value="" />
<input type="submit" name="button" id="button" value="提交" />
<!--这里不需要form,因为提交时call一个函数
<script type="text/javascript">
$(document).ready(function(){ //DOM的onload事件处理函数
$("#button").click(function(){ //当按钮button被点击时的处理函数
postdata(); //button被点击时执行postdata函数
});
});
function postdata(){ //提交数据函数
$.ajax({ //调用jquery的ajax方法
type: "POST", //设置ajax方法提交数据的形式
url: "ok.php", //把数据提交到ok.php
data: "writer="+$("#writer").val()+"&pass="+$("#pass").val(), //输入框writer中的值作为提交的数据
success: function(msg){ //提交成功后的回调,msg变量是ok.php输出的内容。
alert("数据提交成功"); //如果有必要,可以把msg变量的值显示到某个DIV元素中
}
});
}
</script>
后台文件:
<?php
require "config.php";
require "conn.php";
$writer=$_POST['writer'];
$pass=$_POST['pass'];
mysql_query("insert into user values(0,'$writer','$pass')",$db);
//echo $_POST['writer'];
?>