28, May 2012

Require to come from a certain page - webmaster forum

 
Webdigity webmaster forums
[ 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
Instabuck - The easy way to sell digital products online

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


Philippine Beaches


« on: Apr 19, 2007, 02: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, 02:39:10 pm by vbignacio »


Last blog : Bingag Beach, Bohol, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Apr 19, 2007, 02: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 or twitter

Last blog : Butterfly Marketing 2.0
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #2 on: Apr 19, 2007, 02:47:15 pm »

maraming salamat! (thank you very much)


Last blog : Bingag Beach, Bohol, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #3 on: Apr 19, 2007, 02:54:07 pm »

No worries man Cool

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
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....

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?
May 28, 2012, 08:33:44 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!






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