Created
April 11, 2020 12:47
-
-
Save biplab3/67afd2ec97ab12cd47ac77cd4c25b3cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> | |
Name: <input type="text" name="username"> | |
<input type="submit" name="save" value="submit"> | |
</form> | |
<?php | |
if ($_SERVER["REQUEST_METHOD"] == "POST") { | |
// collect value of input field | |
$username = $_REQUEST['username']; | |
if (empty($username)) { | |
echo "Username is empty"; | |
} else { | |
echo $username; | |
} | |
} | |
?> | |
</body> | |
</html> | |
or | |
<html> | |
<body> | |
<form method="post" action=""> | |
Name: <input type="text" name="username"> | |
<input type="submit" name="save" value="submit"> | |
</form> | |
</body> | |
</html> | |
<?php | |
if (isset($_POST['save']) //here 'save' is the name attribute of the button field | |
{ | |
// collect value of input field | |
$username = $_POST['username'];//here username is the field name of the input type element | |
echo $username; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment