nkosinathi Posted November 25, 2010 Share Posted November 25, 2010 Hi All Thanks in advance for your help. I want to have to following query string Type=myparam&Username=dazd&Password=nk98830&id=0&Cols_Returned=numfrom,sentdata But my code returns the following Type=myparam&Username=dazd&Password=nk98830&id=0&Cols_Returned=%2F%22numfrom%2F%22%2C%2F%22sentdata%2F%22 Below is the code: $data= array( "Type"=> "myparam", "Username" => "dazd", "Password" => "nk98830", "id" => "0", "Cols_Returned" => '/"numfrom/",/"sentdata/"' ) ; //This contains data that you will send to the server. $data = http_build_query($data); //builds the post string ready for posting echo "The Query String is "; echo $data; Regards Quote Link to comment Share on other sites More sharing options...
MrXHellboy Posted November 25, 2010 Share Posted November 25, 2010 Why would you want a human readable url query string with passwords and usernames? This is very vulnerable for malicious visitors! its not smart, especially with passwords. Dont do that! Use $_POST instead! IF you still want this.... Dont use http_build_query as this will return a encoded url query string. You have to build this manually like page.php?Type=myparam&Username=dazd&Password=nk98830&id=0&Cols_Returned=numfrom,sentdata replace the values with vairables so it will be dynamically Quote Link to comment Share on other sites More sharing options...
nkosinathi Posted November 25, 2010 Author Share Posted November 25, 2010 Thanks for your query string advice but i am accessing somebody's API with this so its not my decision on human readable url query string . DOing it manually, not sure. Will try this and see what happens. Quote Link to comment Share on other sites More sharing options...
suma237 Posted November 25, 2010 Share Posted November 25, 2010 please refer this article http://php.net/manual/en/function.http-build-query.php <?php $post_url = ''; foreach ($_POST AS $key=>$value) $post_url .= $key.'='.$value.'&'; $post_url = rtrim($post_url, '&'); ?> You can then use this to pass along POST data in CURL. <?php $ch = curl_init($some_url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_url); curl_exec($ch); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.