Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
$_POST - Used to collect form data after submitting an HTML form. Also used to pass variables
SUBMITTED BY:
henry1874w
DATE:
June 17, 2017, 1:20 p.m.
FORMAT:
Text only
SIZE:
422 Bytes
Raw
Download
Tweet
HITS:
202
Go to comments
Report
<!DOCTYPE html>
<html>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
Name: <input type="text" name="fname">
<input type="submit">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// collect value of input field
$name = $_POST['fname'];
if (empty($name)) {
echo "Name is empty";
} else {
echo $name;
}
}
?>
</body>
</html>
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus