note 65602 deleted from ref.array by bjori
| From: | bjori@php.net | Date: | Sat, 03 Jun 2006 11:08:33 +0000 |
| Subject: | note 65602 deleted from ref.array by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-113091@lists.php.net to get a copy of this message | ||
Note Submitter: spongebob3 at hotmail dot com
----
Using $_GET as an array.
Values that are inputted in the GET of a page (e.g.
www.mysite.com/file.php?parametera=1¶meterb=2 - the parametera and parameterb), can be used
in another link, transferring the parameters to another page.
Use the following code:
<?php
$header = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?";
for ($i=0; $i<count($_GET); $i++)
{
$header .= key($_GET)."=".$_GET[key($_GET)]."&";
next($_GET);
}
$header = substr($header,0,strlen($header)-1);
?>
<a href="<? echo $header; ?>¶meterc=3">Link</a>
The link will be linked to the site
http://www.mysite.com/file.php?parametera=1¶meterb=2¶meterc=3
Parametera and parameterb will easily be transferred to the page the link links to. You won't
have to know which GET's are included.
Thus, the GET-parameters are kept, and can be used on another page. This prevents using of various
forms.