Variable Passing in include() and requrie()?
Posted: Tue Mar 25, 2003 4:01 am
Hello guys!
Here's my platform:
1. Apache 1.3.x
2. PHP 4.3.0
3. MySQL (Latest build - I think)
I have a file called a.php. This file takes 2 values from a form. The values are: $username and $password. After getting the values, these two are stored in cookie variables namely $USERNAME and $PASSWORD. Now, depending on the value of $username and $password, the page will redirect to either:
1. admin area (admin.php) - if the username-password combo is correct and user is 'administrator'
2. member area (member.php) - if the username-password combo is correct and user is not 'administrator'
3. error page - if username-password combo is incorrect.
Now, for both the admin.php and the member.php, I have 3 include statements on top of the file. The first 2 include statement contains the values from 2 config files. The 3rd include statement is actually a file which contains code for instantiating a class.
The class handles authentication. Meaning, it looks for the value of $_COOKIE['USERNAME'] and $_COOKIE['PASSWORD'] and matches it with the database. In short, it is almost the same as that what was being done in a.php. The only difference is that this class function takes value from the $_COOKIE globalvariable while a.php takes its value from $_POST.
My problem is, I am being told that I am not allowed to access the member.php or admin.php (assuming I logged in as a member or as 'administrator'). It seems like even if some variables are used in the 3rd include file (let's call this check.php), those same variables are not accessible in the admin.php or member.php. However, when I copy the code from check.php and paste it in admin.php or member.php, the code works fine.
The question is, is there an issue with the superglobal variables with regard to include() and require()?
Here's my platform:
1. Apache 1.3.x
2. PHP 4.3.0
3. MySQL (Latest build - I think)
I have a file called a.php. This file takes 2 values from a form. The values are: $username and $password. After getting the values, these two are stored in cookie variables namely $USERNAME and $PASSWORD. Now, depending on the value of $username and $password, the page will redirect to either:
1. admin area (admin.php) - if the username-password combo is correct and user is 'administrator'
2. member area (member.php) - if the username-password combo is correct and user is not 'administrator'
3. error page - if username-password combo is incorrect.
Now, for both the admin.php and the member.php, I have 3 include statements on top of the file. The first 2 include statement contains the values from 2 config files. The 3rd include statement is actually a file which contains code for instantiating a class.
The class handles authentication. Meaning, it looks for the value of $_COOKIE['USERNAME'] and $_COOKIE['PASSWORD'] and matches it with the database. In short, it is almost the same as that what was being done in a.php. The only difference is that this class function takes value from the $_COOKIE globalvariable while a.php takes its value from $_POST.
My problem is, I am being told that I am not allowed to access the member.php or admin.php (assuming I logged in as a member or as 'administrator'). It seems like even if some variables are used in the 3rd include file (let's call this check.php), those same variables are not accessible in the admin.php or member.php. However, when I copy the code from check.php and paste it in admin.php or member.php, the code works fine.
The question is, is there an issue with the superglobal variables with regard to include() and require()?