Home  >  Article  >  Backend Development  >  What is the php form submission method?

What is the php form submission method?

藏色散人
藏色散人Original
2021-07-26 09:15:167469browse

php form submission method: 1. Use PHP $_REQUEST to collect the data submitted by the HTML form; 2. Use $_POST to collect the form data after submitting the HTML form with "method="post""; 3. Use $ _GET collects data submitted by an HTML form.

What is the php form submission method?

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php form submission method

1. Collect data submitted by HTML forms, PHP $_REQUEST is used to collect data submitted by HTML forms.

<!DOCTYPE html>
<html>
<body>

<form method="post" action="<?php echo $_SERVER[&#39;PHP_SELF&#39;];?>"> #$_SERVER[&#39;PHP_SELF&#39;]是获取当前文件的路径
Name: <input type="text" name="fname">
<input type="submit">
</form>

<?php 
$name = $_REQUEST[&#39;fname&#39;]; #$_REQUEST[&#39;fname&#39;]获取前面name="fname"的输入值
echo $name; 
?>

</body>
</html>

2.PHP $_POST is widely used to collect form data after submitting an HTML form with method="post". $_POST is also commonly used to pass variables.

<html>

<body>

 

<form method="post" action="<?php echo $_SERVER[&#39;PHP_SELF&#39;];?>">    

Name: <input type="text" name="fname">

<input type="submit">

</form>

 

<?php 

$name = $_POST[&#39;fname&#39;]; 

echo $name; 

?>

#action here can be modified to other php files to process the submitted data

html file

php file

##3.PHP $_GET can also be used to collect form data after submitting an HTML form (method="get").

$_GET can also collect data sent in the URL.

The second method of getting submission information

Postscript:

When writing Chinese, an exception will appear. Add

64de5ac3a53af78f54f5fb1b525d83be Then

recommended learning: "

PHP Video Tutorial"

The above is the detailed content of What is the php form submission method?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn