$_POST is basically used to accumulate form data after submitting an HTML form .
$_POST is submit data with method="post". $_POST is also widely used to pass variables.
You can see below example of $_POST.
<!DOCTYPE html>
<html>
<body>
<form method="post" action="">
Country: <input type="text" name="country">
<input type="submit">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//here post input field
$Country_name = $_POST['country'];
//now check the condition
if (empty($Country_name)) {
echo "Country is empty";
} else {
echo $Country_name;
}
}
?>
</body>
</html>
Output will come following:
If Country_name is empty
then, output will come
Country is empty
If Country_name is not empty
then output will come
Country_name which you will give in input field
suppose you will give "USA" in input field
then output will come
USA
0 Comment(s)