Jump to: navigation, search

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

Php form post 1.png

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

Php form post 2.png

Related Links


  1. HTML POST
  2. HTML GET
  3. HTML Textarea
  1. HTML Hidden Field
  2. HiddenField Multiple Pages
  3. HTML Password
  1. HTML Textbox
  2. HTML Checkbox
  3. HTML Radio
  1. Drop down list
  2. Pass value uses URL
  3. Pass value uses URL 2.
  4. Multiple Submit Buttons
Navigation
Web
SQL
MISC
References