Why does my action attribute not direct to other page?

Hi there,

I practice some coding about form and input attribute, but action attribute with form tag keep submit stay on the same page.

I copied and pasted same code from W3C, which works on their web, but doesn’t work on my browser. I use safari and chrome.

Here is my coding.

Many thanks

type or paste code here

<form action="/action_page.php" target="_blank" method="get">
        <label for="username">Username:</label>
        <input type="text" id="username" name="username" value="" maxlength="10" required> <br>
        <!-- text attribute input text  -->
        Your Name: <input type="text" name="name" required> <br>
        <br>
        <label for="password">Password</label>
        <input type="password" id="password" name="pwd" required> <br>
        <!-- password attribute hides password -->
        Gender: Male<input type="radio" name="gender" value="Male"> Female<input type="radio" name="gender" value="female"> Not to tell <input type="radio" name="gender" value="0" checked><br>
        <!-- radio is single choice. Single choice sections must all under same name attribute-->
        Hobby: Swimming <input type="checkbox" name="hobby" value="swimming" checked> Basketball <input type="checkbox" name="hobby" id=""> <br>
        <!-- checkbox is multiple choices  -->
        <!-- Name is used to differ different elements -->
        <input type="submit" value="FREE SIGN UP">
        <!-- Button function need to bw combine with JS -->
        <input type="button" value="get SMS code"> <br>
        
    </form>

To use this you need to be running a PHP-enabled web server on your computer and have a file named action_page.php in the server root that will process the data from your form.

I’m guessing they were just showing you an example of how you would call a script using the action attribute but didn’t actually intend for you to use it.

Thanks bbsmooth.

I hit submit and there is nothing happening. If I want get something back from web, I need a PHP-enabled web server, even if returning message is can not found the page or server. Is this understanding correct?

Thanks

Correct, the URL you put in the action attribute has to be a functioning URL that can process the data from your form.