Jump to content

[SOLVED] Reading all the URL parameters


Rauldinho

Recommended Posts

Hi, i wanted to know how i can read all the parameters coming from the URL in PHP. For example:

 

www.something.com?a=1&b=2&c=3

and then in a php file i have something like a cycle that gives me an output like this:

First Parameter: a is 1

Second Parameter: b is 2

Third Parameter: c is 3

 

Thanks for any help, hope i made myself clear!

Link to comment
https://forums.phpfreaks.com/topic/38542-solved-reading-all-the-url-parameters/
Share on other sites

ok, i think i didn't explain myself completely. What i want is to GET all those parameters but i don't know how many of them are. I want to make a cycle that goes through the URL and gives me all the parameters that were sent. thank you for answering

Here an example with a conditon of page=correct_page there for if the user came from the correct page there get the informaion they want,But if the user comes to the page directly there get a sorry message.

 

 

test.php

 

<?php
echo"<a href='test_result.php?page=correct_page&a=1&b=2&c=3'>test</a>";
?>

 

test_result.php


<?php

if($_GET['page']=="correct_page"){

$one=$_GET['a'];
$two=$_GET['b'];
$three=$_GET['c'];

echo"
First Parameter: a is $one
<br>
Second Parameter: b is $two
<br>
Third Parameter: c is $three
";

}else{

echo "sorry you did not come from the correct page";

?>

Hi, i wanted is to list all the parameters that i get. Here's the solution that i came with and i works for what i need right now. Thanks for all your help! (the vars are in spanish but it hope it can be of help for anybody)

 

    $ParametrosTotal = array_keys($_GET);

    foreach ($ParametrosTotal as $Parametro)

    {

        $ParametroValor = $_GET[$Parametro];

        echo "$Parametro = $ParametroValor";

echo "<br/>";

    }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.