In the process of website development, we usually encounter related operations on php form forms. For example, if PHP obtains form data with post submission method, how to operate it? If you have read my [How does PHP obtain form form data through the get method? 】In this article, I believe everyone already has a certain understanding of the method of php $_GET[] variable to obtain form data.
Then this article will continue to give you a detailed introduction to how PHP obtains form form data through the post method.
There are specific code examples below:
1. Form form code (post method submission form example):
<html> <head> <meta charset="utf-8"> <title>form表单post方法示例</title> </head> <body> <form action="/test/test.php" method="post" > <form action="test.php" method="post"> 名字: <input type="text" name="fname"><br> 年龄: <input type="text" name="age"><br> <input type="submit" value="提交"> </form> </form> </body> </html>
Access through browser, the effect is As shown below:
As shown above, we enter the name and age and click submit to the test.php file.
2. The test.php code is as follows (php gets post data):
<?php header("content-type:text/html;charset=utf-8"); //设置编码 ?> 欢迎 <?php echo $_POST["fname"]; ?>!<br> 你的年龄是 <?php echo $_POST["age"]; ?> 岁。
Here we get the form through the PHP $_POST[] variable The form data is the fname and age parameters (recommended to refer to Chapter 2 of PHP Zero Basics Introductory Tutorial: PHP Form). After submission, the browser access result is as follows:
You can notice here that no form parameters appear in the link in the browser address bar. That is to say, the form information submitted by PHP obtained through the post method is not displayed at all in the address bar. In web form design, most people use the post submission method because it is much more secure than the get method for submitting forms, can avoid the leakage of sensitive information, and there is no limit to the amount of information sent by post. But since the variable does not appear in the URL, the page cannot be bookmarked.
The above content is about the specific method and function of PHP to obtain post submission form data. It has certain reference value and I hope it will be helpful to friends in need.
The above is the detailed content of How to get data in form through PHP post method? (code example). For more information, please follow other related articles on the PHP Chinese website!

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Alipay PHP...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools