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!

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

 

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.