Jump to content

[SOLVED] breaking up the query string dynamicly?


dj-kenpo

Recommended Posts

I know this is a weird question, but bear with me.

 

using $Get_string = $_SERVER['QUERY_STRING']; to receive a query string such as

month=may&$day=15&year=2006

 

so that $Get_string = "month=may&$day=15&year=2006"

 

can I separate the values and turn them into variables? (like a normally would with a url get)

 

$month = "may"

$day= "15" etc

 

it would be great to just do $_GET on the url but I'm sending the string as a variable to another script... so i can't just go the easy route.

 

hope this question makes sense

 

thanks, cheers!

huge security risk... for example... anybody could type in ?month=12&year=2006&security=1|0|1|1... and if you have a $_SESSION[security], it just got changed to 1|0|1|1, and if you use that way of securing... they then can have full access... or whatnot...

ahhh, I see.

 

I just found string parse, so I think that will work.

 

it also seems more secure. do you agree? I think it answers another guys question too...

 

http://ca.php.net/manual/en/function.parse-str.php

 

<?php

$str = "first=value&arr[]=foo+bar&arr[]=baz";

parse_str($str);

echo $first;  // value

echo $arr[0]; // foo bar

echo $arr[1]; // baz

 

parse_str($str, $output);

echo $output['first'];  // value

echo $output['arr'][0]; // foo bar

echo $output['arr'][1]; // baz

 

?>

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.