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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bordman
Forum Newbie
Posts: 16
Joined: Thu Jan 26, 2006 8:20 am
Location: RI

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

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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
bordman
Forum Newbie
Posts: 16
Joined: Thu Jan 26, 2006 8:20 am
Location: RI

Sessions eh...

Post 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:
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

to redirect

Code: Select all

header("Location: index.php");
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

remember to use a full url when using header('Location: ...') ;)
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

feyd wrote:remember to use a full url when using header('Location: ...') ;)
I hardly use absolute URLs...can you tell me why?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.)
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I've always built the full url dynamically.. which is quite simple.

viewtopic.php?t=37950
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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:
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post 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.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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
Post Reply