Hello and welcome to the Webmasters Forums!. This is the best place to get webmasters resources for free. Get $2 for free today, read more - Make your payment today. Download premium and professional templates for free. Get free web hosting without ads, read more. You can get lot more by simply join with this forum. To gain full access to the forums you must sign up for a free account.


Post Reply  Post Thread 

Redirection

Post Bank
Posting Manager
******

Posts: 995
Group: Forum Team
Joined: Sep 2006
Status: Online
Make money from now. You can make money just for posting on this forum. Every discussions on this community gives you more money. $2 minimum payout. So get your payment today, SignIn with this forum.

Signin to Remove this Post

bomber
Junior Member
*


Posts: 34
Group: Registered
Joined: Sep 2006
Status: Offline
Reputation: 0
Points: 250 (Donate)
Post: #1

Big Grin Redirection


Redirection is sending someone from one page to another. Or maybe reloading the current page. With PHP, as long as no data has been sent to the browser yet (any HTML, any echo�? �? commands, etc) you can send an additional HTTP header to the browser that tells it to go somewhere else:

PHP Code:
<?
if (!headers_sent()) {
header("Location: http://www.webmasters-forum.info");
exit;
  }
?>


The exit statement is important, because you don't want to bother running the rest of the whole script again when no one's looking. The headers_sent() function returns TRUE if the headers have already been sent - if they have and you try to use the header() function, PHP throws a wobbly and prints errors to the screen and stuff. Very unprofessional.

This post was last modified: 02-10-2006 05:52 PM by bomber.

18-09-2006 11:46 PM
Find all posts by this user Quote this message in a reply
walsh
Senior Member
****


Posts: 442
Group: Registered
Joined: Oct 2006
Status: Offline
Reputation: 0
Points: 768 (Donate)
Post: #2

RE: Redirection


using only the code:

PHP Code:
header("Location:  http://www.yoursite.com"); 


is necessary. It will work.


02-10-2006 05:49 PM
Find all posts by this user Quote this message in a reply
clookid
Advanced Member
***


Posts: 184
Group: Registered
Joined: Oct 2006
Status: Offline
Reputation: 4
Points: 134 (Donate)
Post: #3

RE: Redirection


Thank you, redirection isn't taught on most PHP tutorial sites. At last I have learnt how to redirect from one page to another.


Veebra Articles - Computer and technology related articles.
08-10-2006 08:54 AM
Find all posts by this user Quote this message in a reply
addik
Member
**


Posts: 109
Group: Registered
Joined: Oct 2006
Status: Offline
Reputation: 2
Points: 0 (Donate)
Post: #4

RE: Redirection


Oooo another sweet PHP stuff.
I am really thrilled about what can PHP do.
Thanks for sharing, bomber.

08-10-2006 04:05 PM
Find all posts by this user Quote this message in a reply
bojomojo
Senior Member
****


Posts: 363
Group: Registered
Joined: Sep 2007
Status: Offline
Reputation: 1
Points: 256 (Donate)
Post: #5

RE: Redirection


bomber Wrote:
Redirection is sending someone from one page to another. Or maybe reloading the current page. With PHP, as long as no data has been sent to the browser yet (any HTML, any echo? ? commands, etc) you can send an additional HTTP header to the browser that tells it to go somewhere else:

PHP Code:
<?
? ? ? ?  if (!headers_sent()) {
? ? ? ? ? ?  
header("Location:? ? http://www.webmasters-forum.info");
? ? ? ? ? ?  exit;
? ? ? ?  }
?>? ? 


The exit statement is important, because you don't want to bother running the rest of the whole script again when no one's looking. The headers_sent()? ? function returns TRUE if the headers have already been sent - if they have and you try to use the header()? ? function, PHP throws a wobbly and prints errors to the screen and stuff. Very unprofessional.

what are the ?s for?

walsh Wrote:
using only the code:

PHP Code:
header("Location:  http://www.yoursite.com"); 


is necessary. It will work.


yes, i have been always doing this, or the load page thing.. and they both work gr8


Paid to Post webmastering forums, high rates | Fastest free image host.


Tech Blog, latest offers like free domains, hosting and everything
08-09-2007 09:51 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ivenms
Administrator
*******


Posts: 2,177
Group: Administrators
Joined: Sep 2006
Status: Offline
Reputation: 14
Points: 4389 (Donate)
Post: #6

RE: Redirection


bojomojo Wrote:
what are the ?s for?


That is because of unformatted characters. Just shows the tabs used. I edited the code.


Read: General Rules & Policies before posting.
Make Money By Posting | Earning and Exchanging Points | Add Your Links
08-09-2007 05:51 PM
Find all posts by this user Quote this message in a reply
bojomojo
Senior Member
****


Posts: 363
Group: Registered
Joined: Sep 2007
Status: Offline
Reputation: 1
Points: 256 (Donate)
Post: #7

RE: Redirection


that works just the same and save some lines.. its the same function ofcourse Big Grin


Paid to Post webmastering forums, high rates | Fastest free image host.


Tech Blog, latest offers like free domains, hosting and everything
08-09-2007 06:33 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites
Rate This Thread:

Forum Jump:

Sign In to Remove Ads

Download 1000's of web templates. Unlimited access!
World's Best Web Hosting
Resources

Recommended Sites:



Visit our Sponsors!

Current time: 02-12-2008, 09:01 AM


Copyright © 2002-2008 MyBB Group
Powered By MyBB