tags:

views:

46

answers:

6

Guys, i have a problem with POST and i hope someone can help me. I have two pages, A and B. I need to send some data through POST from A to B, and B can't be modified in any way. How can i send my POST data from A to B, using PHP? The thing is: i don't need to just send the data, i need to go to the page as well, while sending the post, since B creates a cookie that i need.

header + curl? fsockopen? curl only?

A: 

not entirely sure what you are asking, or if i am simplifying it but check out this:

http://www.w3schools.com/php/php_post.asp

If all you need to do is send data from page A to page B and then navigate to page B, then set the action of the form to page b, so when you hit the button, you will navigate there.

A: 

If something is just too complicated, maybe you're going on the wrong way.

Why do you need such a thing? Can't you just redirect to that page using a form with action="post"? This is the most used way to do what you want, almost every site use this.

If not, tell us the real problem, what you said is a solution to a problem.

Guilherme Oenning
A: 

Basically you need to create a form and set the action to equal B and the method to 'POST', and then have the data you want to send in input tags and don't forget to give each input tag a name and then add a submit button.

When one clicks on the submit button it will send the data to page B and transfer you to that page

Napoleon
I need to send that info in the background, i can't have a form. I tried using cURL along with header, but didn't work well, since cURL sent the post data, and header sent to the page. Two different connections.
Daniel San
In short terms, i have to redirect the user to another page with POST data in this redirection.
Daniel San
A: 

Your question is little unclear .

In page A, you need to set the form action for example then you can get your values in page B and also you will navigated to page B

gowri
In page A i have an array that i want to pass as POST data.
Daniel San
A: 

Guys, i don't have a form. I simply have a PHP file (page A) and i need to redirect the user that opens page A to page B, and within this redirection, sent some POST data. I can't send by GET, i can't send by SESSION, just POST.

Daniel San
A: 

If you need the cookies fro a different domain to be set to a client / visitor, you'll have to get them there, which essentially means they will have to do the post (doing it with curl from you own server still leaves you with no way to set the cookies). The only feasible solution I can see is to perform a post with client-sided scripting (i.e. javascript).

You cannot let the user do a POST with PHP. Period, no way whatsoever. Sure, you can post from your own server what you like, but it won't do a lick of good as long as you cannot get the cookie information to the client, which you can't due to browser security / privacy issues.

Wrikken