Rauldinho Posted February 14, 2007 Share Posted February 14, 2007 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 More sharing options...
fert Posted February 14, 2007 Share Posted February 14, 2007 read about $_GET Link to comment https://forums.phpfreaks.com/topic/38542-solved-reading-all-the-url-parameters/#findComment-184999 Share on other sites More sharing options...
Rauldinho Posted February 14, 2007 Author Share Posted February 14, 2007 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 Link to comment https://forums.phpfreaks.com/topic/38542-solved-reading-all-the-url-parameters/#findComment-185004 Share on other sites More sharing options...
fert Posted February 14, 2007 Share Posted February 14, 2007 http://us2.php.net/manual/en/function.count.php Link to comment https://forums.phpfreaks.com/topic/38542-solved-reading-all-the-url-parameters/#findComment-185007 Share on other sites More sharing options...
redarrow Posted February 14, 2007 Share Posted February 14, 2007 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"; ?> Link to comment https://forums.phpfreaks.com/topic/38542-solved-reading-all-the-url-parameters/#findComment-185015 Share on other sites More sharing options...
redarrow Posted February 15, 2007 Share Posted February 15, 2007 do you want to count how many condition are within the link. Link to comment https://forums.phpfreaks.com/topic/38542-solved-reading-all-the-url-parameters/#findComment-185022 Share on other sites More sharing options...
Rauldinho Posted February 15, 2007 Author Share Posted February 15, 2007 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/>"; } Link to comment https://forums.phpfreaks.com/topic/38542-solved-reading-all-the-url-parameters/#findComment-185026 Share on other sites More sharing options...
redarrow Posted February 15, 2007 Share Posted February 15, 2007 print out the result please cheers. Link to comment https://forums.phpfreaks.com/topic/38542-solved-reading-all-the-url-parameters/#findComment-185028 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.