Forum Moderators: coopster

Message Too Old, No Replies

How to process some variables, then place them into POST and redirect?

Variables can't appear in the url

         

Clark

4:22 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd like to do the following in PHP. Is there a way?

Someone submits a form with data. I want to process the data, then once I'm done with it, take two of the variables, make them post variables and basically redirect the browser as if the user pressed the submit button with data filled in.

The variables can't appear in the url.

Scally_Ally

4:43 pm on Feb 17, 2006 (gmt 0)

10+ Year Member



could you do all of your processing, then write the two vaiables to two hidden input fields surrounded by a form addressed to where you want the redirect to go.

Below that then use some javascript to submit the form.

If i have understood what you want correctly that should work.. i have used that before

Ally

Anyango

4:45 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would Put em in cookies/sesions on the middle page then redirect to the final page and view their values on the final page. If there is any way POST can be simulated/issued without a form, i would also like to know ,how?. ;)

phparion

6:23 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



well what i get from your question is that you want to get the form variables perform your desired operations on them and then use two of them to redirect to some page ...

use

header("location: page.php?var1=value&var2=value");

however, the var1 and var2 would be shown in the URL, for this you can use Sessions like after performaing your operation on form variables then register those two variables in session and use again "header" to go to the other page and then use $_SESSION to use those variables. cookies can be another way too.

does anyone knows a way with which we can use header to redirect but without showing variables in url? in first place is it possible to do so with header?

Clark

11:24 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My keyboard is screwed up dam. Cant use apostrophe arrow keys or even backspace sometimes. My mouse is going bad too. I will never buy Dell again. Apostrophe pops up the FIND bar in Firefox. How weird. Well excuse spelling issues please.

Anyway, Ally"s suggestion is the only one that seems workable to me. But it also seems too much hassle for what I want. Don"t want to use sessions or cookies.

TRIED to quote last line of last reply, but PASTE doesnt" work dam. Pretend QUOT$E HERE, and YES, that"s exactly what I want.

Dam I have to reboot. With all this code in front of me. Hate that. Hate Dell. They used to be good.

jatar_k

5:40 pm on Feb 18, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if you want to use header to do it then the GET method id what you would have to use.

if you want to post to another page/script then use a socket or cURL

coopster

5:53 pm on Feb 18, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The only thing is, jatar_k, I believe Clark wants to redirect to another <form> page with $_POSTed variables filled in. Using a session is probably the easiest way to get this done.

So, not just post form vars somewhere and then redirect a user, but redirect a user and when the user hits the landing page, have the variables filled in on the ladning page form. The title of the thread says "Variables can't appear in the url" so the query string is out.

Clark

5:55 pm on Feb 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



CURL? I've used that before but not to redirect. Are you using use curl to process the resulting page and then pass on the results of standardinput to the client?

I solved my issue another way but it's still an interesting question.

Clark

5:58 pm on Feb 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We were typing at the same time. I don't know much about $SESSION to tell you the truth.

Wouldn't that require modifying the last page where I submit the form? Because the whole reason for this is that the form would be submitted to code that I didn't want to touch.

It's a paid for program that has regular upgrades and I'm sure the $POST vars will never or rarely change, whereas the code itself changes all the time. Don't want to have to redo a hack every time...

coopster

6:08 pm on Feb 18, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Maybe I am the one that is confused here ... wouldn't be the first time ;-) What exactly are attempting to do? I was reading this as ...
  1. User fills out form, presses submit
  2. You process the form data
  3. You grab some form variables and redirect the user to another form
  4. When that form loads, fill in some of the form with the posted variables from the previous process

Can you clarify?

Clark

8:25 pm on Feb 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Drop items 3 and 4 from the list. Rather than display a new form, take two of the variables that were filled out and issue a header redirect, but instead of putting the vars in the url (as GET), have them sent as POST.

coopster

11:35 pm on Feb 18, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Then I stand corrected. jatar_k summed it up well back in msg #6 then.

To answer your question though ...


Are you using use curl to process the resulting page and then pass on the results of standardinput to the client?

Yes.