Include file for LOGIN.
Moderator: General Moderators
If the file perm.inc and the file that is calling it are in the same directory/folder then change you include to
using ../ in the path is making it look in the directory level above the current one
Code: Select all
include "perm.inc";Ok ive tried this and now and I no longer get the error message or the blank screen.
BUt I was expecting a password prompt - this doesnt happen.
Then I thought I realised what happens. As I login to the system as a user who is already in the perm.inc file the system simply allows me to access the protected page without prompting for a username and password. I thought Id test this theory out by deleting myself from the perm.inc file and logging in again. as normal it let me log in to the system but also let me access the protected page so obviously this page is still not protected.
I dont really know where to go from here
BUt I was expecting a password prompt - this doesnt happen.
Then I thought I realised what happens. As I login to the system as a user who is already in the perm.inc file the system simply allows me to access the protected page without prompting for a username and password. I thought Id test this theory out by deleting myself from the perm.inc file and logging in again. as normal it let me log in to the system but also let me access the protected page so obviously this page is still not protected.
I dont really know where to go from here
Hi there,
I am now sure that my script is calling the include file as the echoed statement - "included file" appears on the blank screen.
Heres the script at the top of the page I want to protect.
Heres the include file code
I am now sure that my script is calling the include file as the echoed statement - "included file" appears on the blank screen.
Heres the script at the top of the page I want to protect.
Code: Select all
<?php
include "perm.inc";
if ( permcheck($REMOTE_USER,$ADMIN_USERS)) {
//Do nothing and carry on rendering the page
}
else {
header("Location: https://wwws.soi.city.ac.uk/intranet/plo/test/");
exit;
}
?>Heres the include file code
Code: Select all
<?php
$ADMIN_USERS = array ('chris','deger','pkogan','johnk','carol','renate','peter','bevr','sj368','npalmer','michell');
/* PHP4
echo "included file";
function permcheck ($user, $ValidUser) {
while ( $a = array_shift($ValidUser))
if ($user == $a) return 1;
return 0;
}
*/
// PHP3 version
echo "included file";
function permcheck ($user,$ValidUser) {
while (list ($k,$v) = each ($ValidUser) )
if ($user == $v) return 1;
return 0;
}
?>
This is the error message im now getting - cannot send header information headers already sent.......
Any help please especially the last guy who was helping me a lot.I tested this information by removing my username from the Include file. This now works as when I added myself back to the include file it let me access the form. The only problem I can see now is with the header information.
I can see one way around this - it probably isnt working because of the confusing headers.
can I modify the 'else' statement to send the users to the following location
http://www.soi.city.ac.uk/organisation/ ... index.html
with a message saying You do not have admin rights please contact the administrator at top of the page.
I can see one way around this - it probably isnt working because of the confusing headers.
can I modify the 'else' statement to send the users to the following location
http://www.soi.city.ac.uk/organisation/ ... index.html
with a message saying You do not have admin rights please contact the administrator at top of the page.
Code: Select all
<?php
include "perm.inc";
if ( permcheck($REMOTE_USER,$ADMIN_USERS)) {
//Do nothing and carry on rendering the page
}
else {
header("Location: https://wwws.soi.city.ac.uk/intranet/plo/test/");
exit;
}
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Header information errors are most commonly associated with a) tying to set a cookie after output is sent to the browser; b) trying to start a session after output is sent the browser and there hasn't been a call to ob_start(); and c) trying to use the header() function after output is sent to the browser. In all cases, when using header information setting functions, DO NOT send anything to the browser before the call to the function.