Jump to content

PHP Reffering URL


jackr1909

Recommended Posts

Hi,

 

Can i please have a script for only allowing access to a page from a specific reffering url.

 

Sort of like how if you try and type in: http://www.facebook.com/home.php (the homepage) it would redirect you to a login page. I don't have a MySQL Database and really don't want to.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/233052-php-reffering-url/
Share on other sites

I want to only allow people who have been verified by this array, which is located at /pwdarray/auth.php

to be able to access a members page

 

<?php

 

$usr_username = $_POST['username'];

$usr_password = $_POST['password'];

$usr_name = $_POST['name'];

 

 

$users = array();

$passwords = array();

 

$users[0] = 'user1';

$passwords[0] = 'pass1';

 

$users[1] = 'user1';

$passwords[1] = 'pass1';

 

for($i=0;$i<count($users);$i++){

 

if($users[$i] == $usr_username && $passwords[$i] == $usr_password){

 

 

  header( 'Location: http://www.theblogspace.net/login/loginrefferingtoken.html' ) ;

 

 

} else {

 

  header( 'Location: http://www.theblogspace.net/login/loginfail.php' ) ;

 

}

 

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/233052-php-reffering-url/#findComment-1198600
Share on other sites

that script is going to work, but the issue is that the loginreferingtoken.html page isnt protected by a login check, being a plain html document.

 

what could be done is that you could set a session variable once a user is logged in, and on each page (change extenstions to .php) to check if that session is set, and if not redirect away.

 

 

Link to comment
https://forums.phpfreaks.com/topic/233052-php-reffering-url/#findComment-1198621
Share on other sites

that script is going to work, but the issue is that the loginreferingtoken.html page isnt protected by a login check, being a plain html document.

 

what could be done is that you could set a session variable once a user is logged in, and on each page (change extenstions to .php) to check if that session is set, and if not redirect away.

okay, so i change to:

 

<?php

 

$usr_username = $_POST['username'];

$usr_password = $_POST['password'];

$usr_name = $_POST['name'];

 

 

$users = array();

$passwords = array();

 

$users[0] = 'user1';

$passwords[0] = 'pass1';

 

$users[1] = 'user1';

$passwords[1] = 'pass1';

 

for($i=0;$i<count($users);$i++){

 

if($users[$i] == $usr_username && $passwords[$i] == $usr_password){

 

 

  header( 'Location: members.php' ) ;

 

 

} else {

 

header('login/loginfail.php' ) ;

 

}

 

}

 

?>

 

how would i change the username to a variable so that it redirects to the login page (loginfail.php if the authentication fails)

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/233052-php-reffering-url/#findComment-1198623
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.