GET Array in PHP
Before learning this array you might want to learn the HTTP GET and POST methods in the HTML section of this website.
The forms or any parameter passed to a PHP page with GET method can be retrieved in the PHP page using the inbuilt array $_GET[]. You can retrieve the array values using by using the names of the parameters.Hence $_GET Arrays are associative in nature.
The following is the syntax of a get array.
$user = $_GET["userid"];
An example has been given in the next section which displays a webform with two fields. The form is submitted to the same page. The script displays the parameters submitted using the GET method. A form is submitted using the GET method when the "method" attribute of the form is set to GET or this attribute has not been set at all.
<html>
<head>
<title>$_GET Array</title>
</head>
<body>
<?php
echo "<br>User Id is:".$_GET["user"];
echo "<br>Password is:".$_GET["password"];
?>
<form action=get_array.php method=GET>
UserId:
<input type=text name=user><br>
Password:
<input type=text name=password><br>
<input type=submit value=Submit>
</form>
</body>
</html>
- 566 reads
