Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mimic POST method from script. [urgent]

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
0
0
FR
hello,

does anyone know how I could redirect to another page
without losing data I got from a form on the previous page?
I'm wondering if I should use $http_raw_post_data, and I don't know how to use this.

I am afraid a simple header redirect will damage long strings of text.

Is there a way to mimic the submission of a form (method POST) from inside a script in order to safely pass huge data to another page?

Thanks a lot for the help. My Work...
...and More...
 
You want a form to submit data to a page and then keep the data and send it to another page as well? ***************************************
Party on, dudes!
[cannon]
 
Well, one way to do it is through the query string. I've done this in the past.

You need to create a function that will format the text/information. Basically you need to remove any white space from the fields & replace it with "%20", any new line characters, escape quotation marks & question marks. Anything that would cause havoc for the browser to parse. Any array's would have to be parsed as well.

Then you simply add a header() call or open a new window & window.location() with javascript. You should be able to include the method you want in the header call. But I've always done it with just a simple GET method. It works for me. But there are a few different ways to do this.

Then ofcourse the target .php file would have to be able to work with the data. The best idea would be to keep it as modular as possible. It all depends on what you are trying to accomplish. Another way would be to simply include() the .php file and have the necessary functions parse the data all in one call.

header("Location: - pain4u
 
Thanks Pain4u (errr..you don't wanna hurt me do you!?).

Thanks for the long response.
But to speak franckly, I'm not sure this is the right solution for me.
I would prefer to keep the posted data as it is and just send it somewhere else witout modifying it (safer).

Here is a schema of what I want to do:

[ a form here ] -> [ script validate data ] -> [ if errors, back to form with error message included and all data in fields for modification ]

It's not the first time I do that, but I was doing it the complex way (re-send each variable in a header redirection or save to database).
This time, I would like to send back the data in one block without modifying it.
I'm sure it can be possible.

Thanks again. My Work...
...and More...
 
in that case set all the data to <input type=hidden .. blah
one per item and have a correct button and a confirm button.
This way all data will be passed eith back to the form ( means a slight recode so that you can use :
if (isset($value){
echo your value back to each form field
} else{
empty field

you get the idea I hope .
If you confirm , al data wil be forwarded to final page. ***************************************
Party on, dudes!
[cannon]
 
Thanks Karver.

Unfortunately, I don't want to do that this way because the
second page is only for redirection purpose and isn't supposed to output anything.

Also, even for totally different cases, I would like to know if there is a way to send data the same way forms do with method=POST but with PHP scripts.
If only I could retrieve the posted data and to send it back somewhere else with about one line of code...!

I know this is a difficult question, I hope it will make this thread interesting.

Have a good day.

Insights from everybody are welcome of course.
My Work...
...and More...
 
Hello Sleidia,
I have the same problem that you r talking about so please can u tell me if you solved your problem.
I read the link you provided but it worked in sedning the data to a script instead of redirecting the browser to the script and displaying a normal page.

I hope that you can help me with this.
Just reply to this post and i will know.

Thanks in advance,
Regards
 
Hello,

The only method I found was to output different pages
within the same PHP file (thus, no need to call the
variables again).

For example, you would have a page with a form, a form validation script, a page that shows where the errors are and the thank-you page in a single PHP file.

Sorry if this can't help you that much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top