web 2.0

How to use PHP & POST Method ($_POST,$HTTP_POST_VARS)

How to use PHP & POST Method ($_POST,$HTTP_POST_VARS) Learn PHP how to using POST method and read a php variable from $_POST method.

ShotDev Focus:
- Using PHP & $_POST method.

Example

php_post1.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form action="php_post2.php" method="post" name="form1">
Name
<input name="txtName" type="text">
SiteName
<input name="txtSiteName" type="text">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

php_post2.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?php
echo $_POST["txtName"]."<br>"; // txtName
echo $_POST["txtSiteName"]."<br>"; // txtSiteName
echo "<hr>";

foreach($_POST as $key => $val) // All Key & Value
{
echo $key . " : " . $val . "<br>";
}
?>
</body>
</html>

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_post1.php

Screenshot

PHP POST

PHP POST

.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.