How to Post variables to url using function in php?
I have a problem in php
basically if we want to pass post variable to a url using php we add
But i want to pass it to url using function
for eg
function manish($_POST)
{
$url="https://example.com?";
$url.=$url.$_POST;
}
any idea how to do this?
basically if we want to pass post variable to a url using php we add
But i want to pass it to url using function
for eg
function manish($_POST)
{
$url="https://example.com?";
$url.=$url.$_POST;
}
any idea how to do this?
Replies
-
PraveenKumar PurushothamanYou cannot pass it using a function. But you can do so using headers...
$host = "www.example.com";
$path = "/path/to/script.php";
$data = "data1=value1&data2=value2";
$data = urlencode($data);
header("POST $path HTTP/1.1\r\n");
header("Host: $host\r\n");
header("Content-type: application/x-www-form-urlencoded\r\n");
header("Content-length: " . strlen($data) . "\r\n");
header("Connection: close\r\n\r\n");
header($data); -
PraveenKumar PurushothamanYou can also use CURL to post the data and get the response back, either in a variable or in the output buffer... 😀
-
Prasad AjinkyaA simpler method would be to say method="GET" in your form tag. That way all the form inputs would be submitted as a GET and not as a POST.
A more tedious approach to this would be to take the variables, encode them and then put that in the URL. -
PraveenKumar Purushothaman
Dude, both are simpler... What he is asking is, without a client side interaction, he wants to post the data to another URL got it??? Even I had a same problem but I used header post... 😀kidakakaA simpler method would be to say method="GET" in your form tag. That way all the form inputs would be submitted as a GET and not as a POST.
A more tedious approach to this would be to take the variables, encode them and then put that in the URL. -
Manish Goyal
Yes you are right ,but what i want to do is to pass variables to some url which user can' find to which page variables have been passedkidakakaA simpler method would be to say method="GET" in your form tag. That way all the form inputs would be submitted as a GET and not as a POST.
A more tedious approach to this would be to take the variables, encode them and then put that in the URL.
Anyway it has been done now with the use of curl
You are reading an archived discussion.
Related Posts
😕😕
Firewall
1) Are there any methods available to setup filter ( firewall ) to prevent dangerous information
flows by datagram and connection ??
Ethernet Frame
2) How exactly the...
I've been using Idea cellular for long time now and have found out that the 3G network is now available. Idea representatives had informed me that they were activating the...
Google's been displaying 'Watch This Space' campaign all over their display advertising network via Google Adsense. Google has also dedicated a page to this campaign and it's available on the...
Hello All,
I'm looking for interns for the summer, preferably living in and around Gurgaon. You would be working for India's largest pad printing machine manufacturer (https://www.ritapad.com). This is your...
Remember the Flock browser that enhanced the core Mozilla engine? The social browser offered multiple social network access and gained lot of traction in 2005 - 2008. The browser tightly...