5, September 2008

Require to come from a certain page - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Require to come from a certain page
« previous next »
Pages: [1] Print

Author Topic: Require to come from a certain page  (Read 482 times)
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« on: Apr 19, 2007, 03:36:44 PM »

hello php gurus...

how can i require a visitor to visit page 1 first before going to page 2? if he goes directly to page 2, he will be sent back to page 1.

i made this up but i think its not correct. please correct it.

Code:
<?php
if ($_SERVER['HTTP_REFERER'] != 'page1.php') {
 
 header('Location: page2.php);
} else {
  header('
Locationpage1.php');
}
?>

« Last Edit: Apr 19, 2007, 03:39:10 PM by vbignacio »


Last blog : Liloan Beach, Cebu, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8037
41179 credits
Members referred : 3



« Reply #1 on: Apr 19, 2007, 03:43:24 PM »

The best way to do this is by session as referer information is not standard (some browsers don't send it, some can be blocked by user's software, etc.)

You can add this to your page 1 :

Code:
<?php
session_start
();
$_SESSION['VisitedFirstPage'] = true;
?>


and then put this on page 2 :


Code:
<?php
session_start
();
if ( !
$_SESSION['VisitedFirstPage'] )
  
header('Location: http://blablabla.com/page1.php');
?>


BTW have in mind that a location header should have a valid url (http://.......) not a relative one.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #2 on: Apr 19, 2007, 03:47:15 PM »

maraming salamat! (thank you very much)


Last blog : Liloan Beach, Cebu, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8037
41179 credits
Members referred : 3



« Reply #3 on: Apr 19, 2007, 03:54:07 PM »

No worries man Cool

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6411
Tags : php script Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Require to come from a certain page
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Sep 05, 2008, 03:19:50 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 36.293
Total Topics: 7.476
Total Members: 3.898
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: 1Host

32 Guests, 4 Users online :

15 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.