Private Label and Cobranded VoIP Solutions
BrainCast internet & phone based message/memo recording & reminder organization system
Internet Phone Service and Broadband Phone Service by ViaTalk

Go Back   VoIP Forums, Internet Phone Service Forums, & Web Hosting Forums > CoderForums - Programming Discussion > General Programming Issues > Programming Languages & Technologies > PHP

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-14-2002, 02:12 PM
snipes snipes is offline
Registered User
 
Join Date: Dec 2001
Posts: 43
Protecting content with PHP

I need several of my pages protected from users. However, I must allow the content to be seen if the user just came from PayPal.com (say, after a payment) or from lighthousewd.com. So, I need the pages hidden from everyone except users coming from paypal.com and lighthousewd.com

I tried using some htaccess techniques with no success. I heard there is a simple PHP solution. Anyone know?

Thanks!
__________________
Wes Marlan
wesmarlan@hotmail.com
Reply With Quote
  #2  
Old 03-16-2002, 09:02 PM
Jim Dam Jim Dam is offline
Registered User
 
Join Date: Mar 2002
Posts: 11
You can use the $_SERVER['HTTP_REFERER'] variable to test if the user comes from one of those pages, and then send the correct output based on that.
Reply With Quote
  #3  
Old 03-16-2002, 11:36 PM
snipes snipes is offline
Registered User
 
Join Date: Dec 2001
Posts: 43
That's my problem. HOW do I do it? I don't know any htaccess commands really at all.

Thanks!
__________________
Wes Marlan
wesmarlan@hotmail.com
Reply With Quote
  #4  
Old 03-17-2002, 09:58 AM
Jim Dam Jim Dam is offline
Registered User
 
Join Date: Mar 2002
Posts: 11
PHP Code:
<?PHP
$rd 
$_SERVER['HTTP_REFERER'];
if (
$rd "url1" || $rd "url2") {
    
// include the protected content
    
include("protectedContent.php");
}
else {
    
// return a 404 error
    
header("HTTP/1.0 404 Not Found");
}
?>
Then just have your protected content in protectedContent.php.
Reply With Quote
  #5  
Old 03-17-2002, 03:15 PM
snipes snipes is offline
Registered User
 
Join Date: Dec 2001
Posts: 43
Hey, thanks so much for the php code! That is EXACTLY what I was looking for.

One more question: Do I just put this code in the .htaccess file of the directory/file I need to protect? Or do I create some sort of index.php file that will be read???

Thanks so much for your help!
__________________
Wes Marlan
wesmarlan@hotmail.com
Reply With Quote
  #6  
Old 03-17-2002, 05:28 PM
sylow sylow is offline
PHP/MySQL Developer
 
Join Date: Jan 2001
Posts: 88
use == instead of = in if statement
PHP Code:
if ($rd == "url1" || $rd == "url2"
__________________
Gokhan ARLI
Freelancer for your Php/MySQL Projects
www.sylow.net

Reply With Quote
  #7  
Old 03-17-2002, 09:37 PM
Jim Dam Jim Dam is offline
Registered User
 
Join Date: Mar 2002
Posts: 11
Ah yes, thanks snipes

That would be the PHP page that you need hidden (with the actual file included there).

You would need to repeat that for each page. Alternatively you could use .htaccess and mod_rewrite (using %{HTTP_REFERER}). However, I'm not the one to ask for that code, for mod_rewrite never seems to cooperate with me.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump