In PHP 7, you can handle POST requests using the $_POST superglobal variable. This variable is an associative array that contains the data sent via a POST request.
Here's an example of how you can access the POST data in PHP 7:
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
// Do something with the username and password
}
In this example, we're checking if the request method is POST using the $_SERVER['REQUEST_METHOD'] variable. If it is, we can access the data sent via POST using the $_POST superglobal.
You can access individual POST parameters by their names, as shown in the example with $username
and $password
. Make sure to sanitize and validate the input data to prevent security vulnerabilities.
Note that in PHP 7, the default method for sending form data is POST. However, you can still explicitly specify the method as POST in your HTML form:
<form action="process.php" method="POST">
<!-- form fields -->
</form>
In this example, the form data will be sent to the "process.php" file using the POST method.
上一篇:php执行反向连接
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站