Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.