HTML Form: why action can't have get value in it?

前端 未结 7 2248
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-19 12:07

When i try the following structure, it does\'t send id=value

7条回答
  •  一整个雨季
    2020-12-19 12:31

    Specifying values in the action URI will have no effect, as the values in the URI will get overridden. To demonstrate, try the HTML and PHP code below. The form_test.html file could be renamed, but obviously, the PHP script needs to be named regurgitate.php (or the action in the form needs to be edited).

    form_test.html:

    
    
    Test of setting form action url
    
    
    
    
    
    
    

    regurgitate.php:

    
    
    Test PHP script for testing form action
    
    \n";
    
    foreach ($_GET as $k) {
      echo "\$_GET['$k']: >" . $_GET["$k"] . "<
    \n"; } ?>

    When the submit button is clicked on form_test.html, the URL in my browser becomes something like:

    http://www.example.com/regurgitate.php?Submit=Submit+Query&test=test

    Note there's no "id=value" in the URL.

    The output is:

    In regurgitate.php
    $_GET['Submit Query']: ><
    $_GET['test']: >test<

提交回复
热议问题