1

我刚刚进入 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 &nbsp&nbsp&nbsp&nbsp&nbsp
        <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>
4

1 回答 1

6

Form action="rego.php" 表示您的表单将提交到该文件。

如果你想在 rego.php 之后去其他地方,你应该在任何输出之前从该文件重定向,例如使用位置标头:

// do stuff (registration)

header("Location: another-php.php");
于 2013-01-16T12:58:37.170 回答