Questions about form submission

1, the address on the form to submit questions

 

demo.php

<? PHP
     IF ($ _SERVER [ ' REQUEST_METHOD ' ] === ' the POST ' ) 
    { 
        var_dump ($ _ the POST); // mode request is POST, the current request is generated by the click of a button 
    }
 ?> 
// form processing logic 

<! DOCTYPE HTML> <HTML lang = " EN " > <head> <Meta charset = " UTF-8 " > <title> Log </ title> </ head> <body> // <form Action = " Demo. PHP " Method, = " POST ">
<form action = "<php echo $ _SERVER [ 'PHP_SELF'];??>" method = "post"> // because the file renaming will lead to code changes, robustness is not strong <div> <label for = " userName " > username </ label> <the INPUT of the type = " text " the above mentioned id = " userName " name = " userName " > </ div> <div> <label for = " password " > password </ label> <the INPUT of the type = " password " id="password" name="password"> </div> <button>登陆</button> </form> </body> </html>

① before the processing logic in the form of HTML, HTML for more flexible control of the output

② Because not need to be performed every time the processing logic for the form, it is generally determines the mode request, to determine whether to perform the processing of data

③ general for ease of maintenance, we submits the form to the current page itself

 

2, on the form submission issue

① different manner requested

② transmission parameters different ways, get a url-parameters, post-parameters with the request body

③GET:

  Form data? Parameter passed to the server by the URL

  You can see the content submitted in the address bar

  The data length is limited, because of the limited (2000 characters) URL address length

④POST:

  Form data is passed to the server by requesting the body, we do not see in the interface

  You can submit any type of data, including files

   Since the interface is not visible, the browser does not store, so safer

  Note, never send your password or other sensitive information using GET, use POST

  The request should think clearly the main thing is to pick up, or to send something

 

Guess you like

Origin www.cnblogs.com/shanlu0000/p/11581055.html