The following are three methods for obtaining form data in PHP:
Form partCode:
<Form name = "form1" method = "Post" Action = "">
<Input type = "text" name = "username">
<Input type = "Submit" name = "Submit" value = "Submit">
</Form>
Get form:
<? PHP
Echo ($ http_post_vars ["username"]);
Echo ($ _ request ["username"]);
Echo ($ username );
?>
Method 1 is a common method in versions earlier than 4.0, regardless of how register_globals is set;
Method 2 is a common method in version 4.2 and later, regardless of how register_globals is set;
Method 3 is applicable when register_globals = on is set in PHP. ini.
Supplement:
The content in the $ _ request is actually from $ _ get $ _ post $ _ cookie. The disadvantage is that the variable cannot be determined whether it comes from get post or cookie. It is not applicable to scenarios with strict requirements.