简体   繁体   中英

Adding a link to a HTML submit button

I'm just getting into mysql and i am creating a basic registration page. However, when i click submit, i want to be directed to another page, say a page where you login, as many sites have.

How do i go about allowing the submit button to link to a new page. I know it'll be something simple, but i have looked and can't seem to find much on it.

This is the current code that i've tried:

<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>

Form action="rego.php" means that your form will be submitted to that file.

If you want to go somewhere else after rego.php, you should redirect from that file, for example using the location header, before any output:

// do stuff (registration)

header("Location: another-php.php");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM