Page 1 of 1

New to PHP, how would you do a Server.Transfer in php??

Posted: Thu Jan 26, 2006 8:32 am
by bordman
Hi,
I've used asp with VBscript for a few years now, but I have a new client with an existing site on a Unix server, so I'm forced to use php.

What I'm doing is simple form validation. I've got the form submitting to itself and have all the validation working correctly, displaying a message if there is an error in the form, but I'm stuck :( on how to send all the posted form data to the next form after the validation clears the form. 8O

I know in asp on a Windows server I would use Server.Transfer("mynextpage.asp"). How would I do this in php?? :D

Posted: Thu Jan 26, 2006 8:50 am
by Chris Corbyn
Sessions can store data in PHP throught the duration until the broswer window is closed or the session is stopped.

http://php.net/session

Sessions eh...

Posted: Thu Jan 26, 2006 9:07 am
by bordman
Is this really the best way to do it? There is no equivalent to Server.Transfer("")? :oops:

Even still, after I set the sessions, how do I redirect to the next page?

Thanks for your help!!

:lol:

Posted: Thu Jan 26, 2006 9:12 am
by JayBird
to redirect

Code: Select all

header("Location: index.php");

Posted: Thu Jan 26, 2006 9:40 am
by feyd
remember to use a full url when using header('Location: ...') ;)

Posted: Thu Jan 26, 2006 8:06 pm
by raghavan20
feyd wrote:remember to use a full url when using header('Location: ...') ;)
I hardly use absolute URLs...can you tell me why?

Posted: Thu Jan 26, 2006 9:17 pm
by feyd
There are some browsers, and for some reason I remember some servers too, that do not work with partial URLs for redirections. The reason why? partial URLs are not in the HTTP standard for the Location header (last I checked.)

Posted: Thu Jan 26, 2006 9:55 pm
by raghavan20
But if you are going to use absolute URLs then if comes a necessity to move the entire application to a different Web server with different address then we have to alter all of them...is there a work around for that?

Posted: Thu Jan 26, 2006 10:07 pm
by feyd
I've always built the full url dynamically.. which is quite simple.

viewtopic.php?t=37950

Posted: Thu Jan 26, 2006 10:11 pm
by John Cartwright
I usually stick that variable in an ini file and convert to a constant..

Edit | Feyds way is good too :wink: :wink:

Posted: Fri Jan 27, 2006 4:04 am
by Jenk
Posted a reply in the thread feyd linked to for Burrito's geturl() (re: PHP_SELF) as that leaves a gap for someone to insert gubbins.

Posted: Fri Jan 27, 2006 5:47 am
by Maugrim_The_Reaper
Isn't it a HTTP1.1 requirement?

I also just calculate the URI - I once had very bad experiences relying on setting a constant for the URI, has a habit of being messed with by curious users, who then complain on my forums...;)

Edit:

After checking
http://www.w3.org/Protocols/rfc2616/rfc ... l#sec14.30