Brandyn
Brandyn

Reputation: 1017

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>

Upvotes: 1

Views: 8922

Answers (1)

Dutow
Dutow

Reputation: 5668

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");

Upvotes: 6

Related Questions