start learning
Image 1
53635696364960112

Form data Get

HTTP GET Method It's a standard HTTP request method used to retrieve data from a server. In the context of PHP, it's often used to collect data submitted through HTML forms or to pass data through URLs.


Retrieving Form Data Using GET


<?php
if (isset($_GET['name'])) {
    $name = $_GET['name'];
    echo "Hello, $name!";
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>PHP GET Example</title>
</head>
<body>
  <form method="GET" action="process.php">
        <label for="name">Name:</label>
        <input type="text" id="name" name="name">
        <input type="submit" value="Submit">
    </form>
</body>
</html>

In summary, the GET method in PHP is used to retrieve data from HTML forms or query parameters in URLs. However, be cautious about the type of data you pass through GET requests, and always validate and sanitize user input to ensure security.