<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { // collect value of input field $name = $_REQUEST['fname']; if (empty($name)) { echo "Name is empty"; } else { echo $name; } } ?>
PHP $_GET: it is an array of variable which is passed current scipt link via URL.
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
PHP $_POST : it is an array of variables which is passed current script link via HTTP.
<html>
<body>
Welcome <?php echo $_GET["name"]; ?><br>
Your email address is: <?php echo $_GET["email"]; ?>
</body>
</html>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// collect value of input field
$name = $_POST['fname'];
if (empty($name)) {
echo "Name is empty";
} else {
echo $name;
}
}
?>
Liked By
Write Answer
SERVER , GET, POST method in PHP
Join MindStick Community
You have need login or register for voting of answers or question.
Prakash nidhi Verma
19-Jul-2018PHP $_REQUEST:
PHP $_GET: it is an array of variable which is passed current scipt link via URL.
PHP $_POST : it is an array of variables which is passed current script link via HTTP.