点击注册,数据直接传递给你当前页面,你在代码后面贴一句
<?php
echo $_REQUEST["email"];
?>
填写Email框,点击注册就会显示了
你贴的代码应该不完整,应该还有其他的JS 文件引入, 后面的 script 里的 form 没有调用执行的代码
<?php
echo $_REQUEST["email"];
?>
填写Email框,点击注册就会显示了
你贴的代码应该不完整,应该还有其他的JS 文件引入, 后面的 script 里的 form 没有调用执行的代码
这个看他通去哪的?
不过有人推荐我安装chrome,F12调试,切换到网络选项,我发现它真的调用了form,我实在好困惑。我找到另一个页面,form函数是这样的 。function form(id, controller, action, msg) {
$(id).submit(
function() {
$(msg).load(
'index.php?controller=' + controller + '&action=' + action
+ '&inajax=1', $(id).serializeArray());
return false;
});
}
script.js
function go(controller, action, timeout) {
if (!controller)
controller = 'default';
if (!action)
action = 'index';
var _ = function() {
location.href = 'index.php?controller=' + controller + '&action=' + action;
}
if (timeout)
setTimeout(_, timeout);
else
_();
}
function form(id, controller, action, msg) {
$(id).submit(
function() {
$(msg).load(
'index.php?controller=' + controller + '&action=' + action
+ '&inajax=1', $(id).serializeArray());
return false;
});
}index.php 这个只有一句代码,其他的都在其他文件里面。
<?php
//加载公共文件
include './include/common.inc.php';
//MVC路由
base::go ( $_GET ['controller'], $_GET ['action'] );
?>
页面的代码在这里.这是我提交表单的页面。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>聊天室</title>
<link rel="stylesheet" type="text/css" href="include/style.css" />
<script src="include/jquery.js" type="text/javascript"></script>
<script src="include/script.js" type="text/javascript"></script>
</head><body>
<center><h1>聊天室</h1>
<form method="post" id="regform"><label><em>E-Mail:</em><input
type="text" name="email" /></label> <label><em>密码:</em><input
type="password" name="password" /></label><label><em>确认密码:</em><input
type="password" name="checkpass" /></label><label><em>昵称:</em><input
type="text" name="nickname" /></label>
<button type="submit">注册</button>
<button type="button" onclick="go('member','login')">登录</button>
<span id="messagearea"></span></form>
<script type="text/javascript">form('#regform','member','savereg','#messagearea');</script>
</center></body>
</html>