我刚刚进入mysql,我正在创建一个基本的注册页面。但是,当我点击提交时,我希望被定向到另一个页面,比如说您登录的页面,就像许多网站一样。
如何允许提交按钮链接到新页面。我知道这将是一件简单的事,但我看起来似乎并没有找到太多的东西。
这是我尝试的当前代码:
<html>
<head>
<title>MySQL Test - Registration</title>
<script LANGUAGE="JavaScript">
function testResults() {
window.document.location.href = "http://www.google.com";
}
</script>
</head>
<body>
<form action = "rego.php" method = "POST">
Username:<br/>
<input type = "text" name = "username"/><br/>
Password:<br/>
<input type = "password" name = "password"/><br/>
Confirm Password:<br/>
<input type = "password" name = "passvery"/><br/>
Email:<br/>
<input type = "text" name = "email"/><br/><br/>
Please select your gender:<br/>
<input type = "radio" name = "gender" value = "male"/>Male      
<input type = "radio" name = "gender" value = "female"/>Female<br/><br/>
<input type = "checkbox" name = "agree" value = "agree"/>I agree to the terms and conditions.<br/>
<br/>
<input type = "submit" value = "Sign Up!" onclick = "javascript:testresults()" />
</form>
</body>
</html>
答案 0 :(得分:6)
表单操作=“rego.php”表示您的表单将提交到该文件。
如果你想在rego.php之后去别的地方,你应该在任何输出之前从该文件重定向,例如使用位置标题:
// do stuff (registration)
header("Location: another-php.php");