PHP HTML POST
From w3cyberlearnings
Contents |
PHP $_POST
$_POST to get HTTP POST REQUEST.
Syntax $_POST
$_POST['Name']
Note
$_POST for POST HTTP REQUEST is more secure than the $_GET for GET HTTP REQUEST.
Example 1
<?php if ($_POST) { foreach ($_POST as $name => $value) { echo $name . '=' . $value . '<br/>'; } } ?> <html> <head> <title>POST</title> </head> <body> <html> <head> <title>Reset password</title> </head> <body> <p>Provide your full name and email address to reset your password</p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> First Name:<input type="text" name="first_name"/><br/> Last Name:<input type="text" name="laste_name"/><br/> Email:<input type="text" name="email_add"/><br/> <input type="submit" name="reset_password_user" value="reset password"/><br/> </form> </body> </html> </body> </html>
Output
Example 2
<?php if ($_POST) { $fname = $_POST["first_name"]; $lname = $_POST["laste_name"]; $email = $_POST["email_add"]; if ($fname == "" || $lname == "" || $email == "" || $lname == "") { echo "You do not enter all the requirement <br>"; } else { echo "<br/>"; echo "Thank You!!<br/>"; echo "First Name: " . $fname . "<br/>"; echo "Last Name: " . $lname . "<br/>"; echo "Email: " . $email . "<br/>"; } } ?> <html> <head> <title>POST</title> </head> <body> <html> <head> <title>Reset password</title> </head> <body> <p>Provide your full name and email address to reset your password</p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> First Name:<input type="text" name="first_name"/><br/> Last Name:<input type="text" name="laste_name"/><br/> Email:<input type="text" name="email_add"/><br/> <input type="submit" name="reset_password_user" value="reset password"/><br/> </form> </body> </html> </body> </html>
Output
Related Links
- HTML POST
- HTML GET
- HTML Textarea