473,493 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

old question (perhaps): redirect with POST of data?

A question that has certainly been asked before and I've googled etc.
for answers with no certain outcome...

I'd like my PHP script to redirect the client browser to another page,
POSTing some data at the same time. (To take them back to an html page
showing a form that needs correcting because some data is missing.)
I believe this is either tricky or not possible from what I've seen, but
I'd just like to see what others think currently...

It's a little annoying because plain redirecting is easy and plain POST
to a URL (and get the results back) is easy too, but combining them
seems to be another matter...

thanks!
alex
Jul 17 '05 #1
11 3036
Alex Hunsley wrote:
A question that has certainly been asked before and I've googled etc.
for answers with no certain outcome...

I'd like my PHP script to redirect the client browser to another page,
POSTing some data at the same time. (To take them back to an html page
showing a form that needs correcting because some data is missing.)
I believe this is either tricky or not possible from what I've seen, but
I'd just like to see what others think currently...

It's a little annoying because plain redirecting is easy and plain POST
to a URL (and get the results back) is easy too, but combining them
seems to be another matter...

thanks!
alex

use a combination of sessions, post and get.

If you want the source code limited to one file then pass parameters on
the $_GET parameter list. If you use sessions then pass some of the info
via session variables, also use $_POST forms, all sorts of ways, depends
what works for your requirements

Jul 17 '05 #2
NSpam wrote:
Alex Hunsley wrote:
A question that has certainly been asked before and I've googled etc.
for answers with no certain outcome...

I'd like my PHP script to redirect the client browser to another page,
POSTing some data at the same time. (To take them back to an html page
showing a form that needs correcting because some data is missing.)
I believe this is either tricky or not possible from what I've seen,
but I'd just like to see what others think currently...

It's a little annoying because plain redirecting is easy and plain
POST to a URL (and get the results back) is easy too, but combining
them seems to be another matter...

thanks!
alex
use a combination of sessions, post and get.

If you want the source code limited to one file then pass parameters on
the $_GET parameter list.


I want to avoid just using a GET style URL as it looks unprofessional.
If you use sessions then pass some of the info
via session variables, also use $_POST forms,
What exactly do you mean by $_POST forms?

thanks
alex
all sorts of ways, depends
what works for your requirements


Jul 17 '05 #3
Alex Hunsley wrote:
What exactly do you mean by $_POST forms?


He means from html:
<from action="bla.php" METHOD="POST">
<input type="text" name="color">
</form>

And from php:
$color = $_POST["color"];

Good luck.

Regards,
Erwin Moller
Jul 17 '05 #4
NC
Alex Hunsley wrote:

I'd like my PHP script to redirect the client browser to another
page, POSTing some data at the same time.


Not going to work. If your page sends out a POST request, it
must receive response. You can show that response to the client,
but you may have broken links in it.

There is an alternative, however. If both pages are on the same
server, you can write POST data into session variables and then
redirect without arguments and have the second page retrieve data
from those session variables.

Cheers,
NC

Jul 17 '05 #5
"Alex Hunsley" <la**@tardis.ed.ac.molar.uk> wrote in message
news:lw*******************@fe1.news.blueyonder.co. uk...
A question that has certainly been asked before and I've googled etc.
for answers with no certain outcome...

I'd like my PHP script to redirect the client browser to another page,
POSTing some data at the same time. (To take them back to an html page
showing a form that needs correcting because some data is missing.)
I believe this is either tricky or not possible from what I've seen, but
I'd just like to see what others think currently...

It's a little annoying because plain redirecting is easy and plain POST
to a URL (and get the results back) is easy too, but combining them
seems to be another matter...

thanks!
alex


The following will redirect a POST request.

header("HTTP/1.0 307 Temporary Redirect");
header("Location: $url");

Works the last time I check in IE.


Jul 17 '05 #6
Erwin Moller wrote:
Alex Hunsley wrote:

What exactly do you mean by $_POST forms?

He means from html:
<from action="bla.php" METHOD="POST">
<input type="text" name="color">
</form>

And from php:
$color = $_POST["color"];

Good luck.

Regards,
Erwin Moller


Oh right, I see, thanks!

alex
Jul 17 '05 #7
NC wrote:
Alex Hunsley wrote:
I'd like my PHP script to redirect the client browser to another
page, POSTing some data at the same time.

Not going to work. If your page sends out a POST request, it
must receive response. You can show that response to the client,
but you may have broken links in it.


Yeah, I was ruminating on this earlier on and it is a good point!
I may just receive the resulting HTML (from my post operation) and just
shove that out to the browser.

There is an alternative, however. If both pages are on the same
server, you can write POST data into session variables and then
redirect without arguments and have the second page retrieve data
from those session variables.
Ah, thanks for that clarification, I think one of the other repliers was
hinting at this but they were very vague about it... Cheers,
NC


cheers
alex
Jul 17 '05 #8
Chung Leong wrote:
"Alex Hunsley" <la**@tardis.ed.ac.molar.uk> wrote in message
news:lw*******************@fe1.news.blueyonder.co. uk...
A question that has certainly been asked before and I've googled etc.
for answers with no certain outcome...

I'd like my PHP script to redirect the client browser to another page,
POSTing some data at the same time. (To take them back to an html page
showing a form that needs correcting because some data is missing.)
I believe this is either tricky or not possible from what I've seen, but
I'd just like to see what others think currently...

It's a little annoying because plain redirecting is easy and plain POST
to a URL (and get the results back) is easy too, but combining them
seems to be another matter...

thanks!
alex

The following will redirect a POST request.

header("HTTP/1.0 307 Temporary Redirect");
header("Location: $url");

Works the last time I check in IE.


I may well be able to do it this way... thanks for the tip!
alex
Jul 17 '05 #9
Alex Hunsley wrote:
A question that has certainly been asked before and I've googled etc.
for answers with no certain outcome...


Was Flavell's "Redirect in response to POST transaction"[1] one of
those results?

Even though a 307 response is probably your best bet, it still doesn't
exactly guarantee success (at least in a Web context). Storing the
data between requests, or perhaps using cURL or sockets to perform the
second POST request and return the result, might be better. I haven't
tried either, though.

[snip]

Mike
[1] <URL:http://ppewww.ph.gla.ac.uk/~flavell/www/post-redirect.html>

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 17 '05 #10
Alex Hunsley wrote:
Erwin Moller wrote:
Alex Hunsley wrote:

What exactly do you mean by $_POST forms?

He means from html:
<from action="bla.php" METHOD="POST">
<input type="text" name="color">
</form>

And from php:
$color = $_POST["color"];

Good luck.

Regards,
Erwin Moller


Oh right, I see, thanks!

alex


Anytime.
If you are someday in doubt what you mean, just ask me.
;-)

Regards,
Erwin Moller

Jul 17 '05 #11
Michael Winter wrote:
Alex Hunsley wrote:
A question that has certainly been asked before and I've googled etc.
for answers with no certain outcome...

Was Flavell's "Redirect in response to POST transaction"[1] one of those
results?


Yup, I did find that one.
Even though a 307 response is probably your best bet, it still doesn't
exactly guarantee success (at least in a Web context). Storing the data
between requests, or perhaps using cURL or sockets to perform the second
POST request and return the result, might be better. I haven't tried
either, though.


Yeah, the article seems to say that results are a little unpredictable
and I don't think it would be as reliable as I want...
thanks!
alex

Jul 17 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4871
by: Victor | last post by:
I need to redirect to another web page, but that redirect will include the submission of form data. So, unlike ServerXMLHTTP which stays on the originating web page, I need the script to redirect...
2
2746
by: Darren Oakey | last post by:
G'day - I have a problem that I just can't figure out how to solve, and would desperately love some help!!! We have an existing product (which we don't have control over) which is a web server...
6
16031
by: DotNetGruven | last post by:
I've got a page that does a search... There is an ImageButton on it that allows the user to reset the search. The Click Handler for the button clears out the Data and then redirects to the same...
6
2884
by: Keith Patrick | last post by:
I have to do some programmatic redirects (in several pages) based on URLs I am given from an external source. The URLs have querystrings at the end, but one in particular is about 240 chars long,...
2
4450
by: ETK | last post by:
Hi, I need to POST data to some aspx page and after that redirect to this page ( page isn't on my local server where my page is). Is it possible to do this from aspx code on server side? Thanks,...
1
4239
by: David | last post by:
I need to redirect to a page and HTTP Post data. The Response.Redirect does not work and the HTTPREQUEST option calls the page and waits for a response, but I need to transfer control to the...
3
2415
by: Brano | last post by:
HI all, I am looking to post XML data to a particular page and also redirect to the same page. I have coded a WebReqest code in page0 that posts the XML to the page1 and then the page1 in its...
5
6640
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
I am trying to create ASPX code which will allow me to redirect a user to another site with POST data. I figure that the best way to do this is with JavaScript to the client. Here's what I'm doing:...
56
7173
by: UKuser | last post by:
Hi, 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...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6873
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.