Jump to content

PHP Reffering URL


jackr1909

Recommended Posts

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