Re: Post with redirect?
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Mon, 17 Dec 2007 13:06:20 -0500
Steve wrote:
"taps128" <nstjelja@xxxxxxxxx> wrote in message news:fk5ecm$h6e$1@xxxxxxxxxxxxxxxxxUKuser wrote:On 14 Dec, 16:22, "Steve" <no....@xxxxxxxxxxx> wrote:some time ago I found a nice piece of code that helps me to access a script using post using the standards php streams wrapper"UKuser" <spiderc...@xxxxxxxxxxx> wrote in messageYes it does, unfortunately I have to redirect the user to the page as
news:6c8d667d-a40b-45c2-bc03-94951dbc137f@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 14 Dec, 15:18, "Steve" <no....@xxxxxxxxxxx> wrote:if you collect information via a page called my.php, put the above code in"UKuser" <spiderc...@xxxxxxxxxxx> wrote in messageHi Steve,
news:5202d2ed-02a2-407d-87ca-a6a2b50a283c@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 14 Dec, 14:42, "Steve" <no....@xxxxxxxxxxx> wrote:as a general and theoretical approach:"UKuser" <spiderc...@xxxxxxxxxxx> wrote in messageHi Guys,
news:6d60314f-61f0-4f08-b1ad-b6cf357cac15@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 14 Dec, 12:48, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:don't let the misinformation fool you. it can be done with php. theUKuser wrote:Thanks for your help. Should have realised because its server sideHi,Not easy, and it can't be done with PHP. The browser needs to
I'm not sure if this can be done as I've searched the web and
this
forum.
I am using an online merchant provider and I must post certain
variables to their webforms through a form on my website.
The issue is that I need to gauge whether a user has any items in
their basket to decide which page I redirect them too. I could
obviously use cookies or hidden fields etc but these can be
manipulated.
How can I force a POST but actually redirect the user as well
like a
browser would do? I can do the first part (force the post) as per
this
site (the site appears down, so the link uses the Web Archive):
http://web.archive.org/web/20040628200619/http://www.zend.com/zend/sp...
Its the second bit if I'm not sure whether it can or can't be
done.
If not I'll need to ask the merchant if they allow GET instead.
Many thanks
A
process
the redirect, so you need to do it from the browser end. That
means a
client-side language such as javascript.
cURL could theoretically help you here - but you're asking for a
lot
of
work, especially if there are several pages being handled after the
redirect. You'd have to parse each page to see what to do next.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@xxxxxxxxxxxxx
==================
it
makes it impossible. Any thoughts on how it could be done with
AJAX/JS?
only
thing jerry got right is that it would be a lot of work. what jerry
also
mistakenly forgets is that just about anything you can do with curl,
you
can
do with native php functions...and in this case, the 'just about
anything'
you'd need to be able to do becomes 'anything'. jerry's 'curl could
theoretically' argument then logically negates and invalidates his
'cant
be
done with php' claim.
you're just in for a lot of work. however, it can be done.
I'm not greatly up for a huge deal of work although would be
interested in how you would generally start doing it in PHP. However I
found another posting on a forum which works and is much easier. Not
ideal although we are really only (and i know its aweful) aiming our
website at Javascript users.
function getResponse($uri, $path, $data, $method = 'POST')
{
$method = strtoupper($method);
$socket = fsockopen($uri, 80);
if (!$method)){ $method = 'GET'; }
if (substr($path, 0) != '/'){ $path = '/' . $path; }
if (!is_array($data)){ $data = array($data); }
$message = '';
foreach ($data as $label => $value)
{
$message .= '&' . $label . '=' . $value;
}
if ($method == 'GET'){ $path .= '?' . $message; }
fputs($socket, "$method $path http/1.1\r\n");
fputs($socket, "host: $uri\r\n");
fputs($socket, "content-type: application/x-www-form- urlencoded\r\n");
fputs($socket, "content-length: " . strlen($message) . "\r\n");
fputs($socket, "connection: close\r\n\r\n");
if ($method == 'POST'){ fputs($socket, $message); }
while (!feof($socket)){ $response .= fgets($socket, 512); }
fclose($socket);
return $response;
}
$response = getResponse(
'www.example.com',
'some.page.php' ,
$_POST ,
'POST'
);
// parse, validate, process
effectively, this achieves your html/javascript solution and keeps it all
php.
that help?
Thanks for your detailed response. Would that be able to redirect the
user to the same page as where the data was posted?
it. have my.php post to itself. when you get the post, pass the info on to
the third party via getResponse...then parse the results...you haven't done
any redirecting and the user has used my.php the entire time.
make sense?
its a credit card entry form on a completely separate server. They
don't appear to accept GET requests only POSTS so I somehow need to
get the information and the user to that page.
$postdata = http_build_query(
array(
'var1' => 'some content',
'var2' => 'doh'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents('http://localhost/vjezba/post_u_skriptu_2.php', false, $context);
print_r(explode(' ',$result));
yes, but jerry seems to think that using this method of putting items in a user's cart on another server is impossible...and that using an html form with the same inputs as is native on the server's checkout form to initiate payment is likewise, impossible. he gets hung up on having to use javascript to do a redirect. php and standard html handle all of that just fine. just don't tell him that.
Again, you claim you can do a redirect with posted values in PHP. Let's see you do it, Steve. The entire world is STILL waiting for you to show us how!
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: Post with redirect?
- From: Steve
- Re: Post with redirect?
- References:
- Post with redirect?
- From: UKuser
- Re: Post with redirect?
- From: Jerry Stuckle
- Re: Post with redirect?
- From: UKuser
- Re: Post with redirect?
- From: Steve
- Re: Post with redirect?
- From: UKuser
- Re: Post with redirect?
- From: Steve
- Re: Post with redirect?
- From: UKuser
- Re: Post with redirect?
- From: Steve
- Re: Post with redirect?
- From: UKuser
- Re: Post with redirect?
- From: taps128
- Re: Post with redirect?
- From: Steve
- Post with redirect?
- Prev by Date: Re: secure file uploads and downloads
- Next by Date: Re: secure file uploads and downloads
- Previous by thread: Re: Post with redirect?
- Next by thread: Re: Post with redirect?
- Index(es):
Relevant Pages
|