web 2.0

How to use PHP & GET Method ($_GET,$HTTP_GET_VARS)

How to use PHP & GET Method ($_GET,$HTTP_GET_VARS) Learn PHP how to using GET method and read a php variable from $_GET method.

ShotDev Focus:
- Using PHP & $_GET method.

Example 1 Using $_GET from URL QueryString

php_get1.php

<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<a href="php_get2.php?Name=Weerachai&SiteName=ShotDev.Com">Test  $_GET </a>
</body>
</html>

php_get2.php

<html>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?php
echo $_GET["Name"]."<br>";
echo $_GET["SiteName"]."<br>";
?>
</body>
</html>

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

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

Screenshot

PHP GET

PHP GET

..

Example 2 Using $_GET from Tag <form> and Method GET

php_get3.php

<html>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form action="php_get4.php" method="get" 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_get4.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?php
echo $_SERVER["REQUEST_URI"]."<br>"; // URL
echo "<hr>";
echo $_GET["txtName"]."<br>"; // Get txtName
echo $_GET["txtSiteName"]."<br>"; // Get txtSiteName
echo "<hr>";

foreach($_GET as $key => $val) // Get 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_get2.php

Screenshot

PHP Concat String

PHP Concat String
.
.
.

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 ...

One Response to “How to use PHP & GET Method ($_GET,$HTTP_GET_VARS)”

  1. 3gymnastic…

Leave a Reply

You must be logged in to post a comment.