Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using PHP to post to a form

0 views
Skip to first unread message

Blake

unread,
Dec 9, 2009, 1:46:45 PM12/9/09
to
Howdy,

I have a scenario in which I have two applications that need to share
data. Application A needs to post data to a form in App B and, for
lack of better phrasing, switch the user over to App B. Some of the
data is sensitive, so I'd prefer the user not be able to see it by
viewing the source, so a standard <input type="hidden"> is out, as is
having javascript add the post value for submitting. I can't use
Snoopy or curl (i think), because the final form processor might
initiate a session / set cookies that get lost in Snoopy and/or curl.

The theoretical solution i've come up with is this:
User fills out form and submits it -> my php script appends some post
data, then submits the form to the actual form processor in the 2nd
application -> user arrives form response page for the second system.

Doing this with GET ist trivial, but I can't seem to figure out how to
get it working for POST. Any ideas?

Thanks,

Blake

--

to email, remove the hyphens.

Jerry Stuckle

unread,
Dec 9, 2009, 4:22:40 PM12/9/09
to

Responses always go back to the requesting hose. You cannot do either a
post or a get to another system from your machine and have the response
go back to the user. The response will always go back to your machine -
and you will have to relay that response back to the user.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

Blake

unread,
Dec 9, 2009, 5:53:48 PM12/9/09
to
On Wed, 09 Dec 2009 16:22:40 -0500, Jerry Stuckle
<jstu...@attglobal.net> wrote:

>Blake wrote:
>> Howdy,
>>
>> I have a scenario in which I have two applications that need to share
>> data. Application A needs to post data to a form in App B and, for
>> lack of better phrasing, switch the user over to App B. Some of the
>> data is sensitive, so I'd prefer the user not be able to see it by
>> viewing the source, so a standard <input type="hidden"> is out, as is
>> having javascript add the post value for submitting. I can't use
>> Snoopy or curl (i think), because the final form processor might
>> initiate a session / set cookies that get lost in Snoopy and/or curl.
>>
>> The theoretical solution i've come up with is this:
>> User fills out form and submits it -> my php script appends some post
>> data, then submits the form to the actual form processor in the 2nd
>> application -> user arrives form response page for the second system.
>>
>> Doing this with GET ist trivial, but I can't seem to figure out how to
>> get it working for POST. Any ideas?
>>
>> Thanks,
>>
>> Blake
>>
>
>Responses always go back to the requesting hose. You cannot do either a
>post or a get to another system from your machine and have the response
>go back to the user. The response will always go back to your machine -
>and you will have to relay that response back to the user.

Sorry, I should have been clearer. In a GET scenario, I could grab
the form data, append the data I wanted, then redirect the user to the
appropriate URL (which includes the newly appended form data). In
that case, it's still the original machine doing the form submission,
I'm just modifying the the data it's sending.

Is there not some similar mechanism for POST? Grab the existing post
data, add the post data I want, send it all back to the user with the
correct URL for the form data to be sent?
--
Thanks,

Blake

* to email, remove the hyphens.

The Natural Philosopher

unread,
Dec 9, 2009, 6:17:15 PM12/9/09
to

I cant see how. You could use cookies though I think.

And possibly javascript..

This is how I got a button on a form to connect to a credit card PHP app
on a different secure server..and carry the customers identity across..I
didn't REALLY want to use GET variables for obviuous reasons.

function card_window(url)
{
var cid=document.getElementsByName('customer')[0].value;
document.cookie="cid="+cid +"; version=0; path=/";
window.open("<?echo $locale_secure_server;?>/cd.php","Card","width=480,
top=200, left=260, height=200, resizable=yes");
}

That's invoked by an onclick= event.

Pops up a little separate browser window connected to a different server
runing https.

Jerry Stuckle

unread,
Dec 9, 2009, 7:41:48 PM12/9/09
to

I don't see how you could do that without some javascript on the client
end.

Any way you do it, you need the client to make the request - which means
you need a client-side script - which is not PHP.

Michael Fesser

unread,
Dec 10, 2009, 11:18:11 AM12/10/09
to
.oO(Blake)

>Sorry, I should have been clearer. In a GET scenario, I could grab
>the form data, append the data I wanted, then redirect the user to the
>appropriate URL (which includes the newly appended form data). In
>that case, it's still the original machine doing the form submission,
>I'm just modifying the the data it's sending.
>
>Is there not some similar mechanism for POST? Grab the existing post
>data, add the post data I want, send it all back to the user with the
>correct URL for the form data to be sent?

Not with standard HTTP redirects:

| If the 3xx status code is received in response to a request other than
| GET or HEAD, the user agent MUST NOT automatically redirect the
| request unless it can be confirmed by the user, since this might
| change the conditions under which the request was issued.

Micha

#2pencil

unread,
Dec 10, 2009, 5:12:33 PM12/10/09
to
As long as both Application A & Application B are on the same server,
couldn't you start a session & pass the session ID between
applications?

-#2pencil-

ctclibby

unread,
Dec 11, 2009, 9:23:39 PM12/11/09
to
On Dec 9, 11:46 am, Blake <bl...@custom-fitz-software.com> wrote:
> Howdy,
>
> I have a scenario in which I have two applications that need to share
> data.  Application A needs to post data to a form in App B and, for
> lack of better phrasing, switch the user over to App B. Some of the


Why have two applications? ['PHP_SELF'] can answer its own questions
if set up properly.

ctclibby

Blake

unread,
Dec 28, 2009, 2:16:55 AM12/28/09
to

I'm not sure. They're both on the same physical server, but they're
accessed at different subdomain addresses. So, the app at
foo.blah.com would be feeding data into bar.blah.com. Can you pass
session ID's across that boundary?

--
Blake

*To email, remove the hyphens

Jerry Stuckle

unread,
Dec 28, 2009, 5:47:43 PM12/28/09
to

You can, if your php.ini is set up properly. See session.cookie_domain.

0 new messages