Integrating the user system with the template system

Ask about a PHP problem here.
Post Reply
saycey
Posts: 3
Joined: Thu Sep 22, 2011 10:26 pm

Integrating the user system with the template system

Post by saycey »

Hi

I'm having a problem integrating the user system with the template system...When I load up a page I keep getting the redirect loop error...I have looked through the code but have no idea what is causing the error.

Below is my init.inc.php file.
<?php
 
session_start();
 
if (empty($_GET['page'])) {
        header('Location: home');
        die();
}
$core_path = dirname(__FILE__);
 
$pages = scandir("{$core_path}/pages");
unset($pages[0], $pages[1]);
 
foreach ($pages as &$page) {
        $page = substr($page, 0, strpos($page, '.'));
}
 
if (in_array($_GET['page'], $pages)) {
        $include_file = "{$core_path}/pages/{$_GET['page']}.page.inc.php";
}else{
        $include_file = "{$core_path}/pages/home.page.inc.php";
}
 
//login starts below
 
$exceptions = array('register', 'login');
 
//$page1 = substr(end(explode('/', $_SERVER['SCRIPT_NAME'])), 0, -4);
 
if (in_array($include_file, $exceptions) === false){
        if (isset($_SESSION['username']) === false){
                header('Location: login');
                die();
        }
}
 
mysql_connect('localhost', 'user', 'pass');
mysql_select_db('db');
 
$path = dirname(__FILE__);
 
include("{$path}/core/user.inc.php");
 
?>
Anyone know whats wrong :S

Thanks,
Saycey :)
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Integrating the user system with the template system

Post by jacek »

I have seen this before ;)

what does your .htaccess file look like ?
Image
saycey
Posts: 3
Joined: Thu Sep 22, 2011 10:26 pm

Re: Integrating the user system with the template system

Post by saycey »

RewriteEngine On

RewriteRule ^([a-zA-Z_]+)/?$ index.php?page=$1 [QSA]
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Integrating the user system with the template system

Post by jacek »

Okay, that looks pretty much fine. Are you being sent to home or login ?
Image
saycey
Posts: 3
Joined: Thu Sep 22, 2011 10:26 pm

Re: Integrating the user system with the template system

Post by saycey »

Fixed the redirect error but I dont think any of the login part is working since protected.php isnt protected...
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Integrating the user system with the template system

Post by jacek »

saycey wrote:Fixed the redirect error but I dont think any of the login part is working since protected.php isnt protected...
Put your self on the other side of that question. From what you told us "the login part is [not] working" how can we help !?
Image
Post Reply