Hi,
I’m developing a web application that deals with login as usual. However, somehow I’m getting stuck on something.
I have a controller which basically reads a config file and depending on the settings there does several things.
One of them is that is puts together a variable that holds a string that is actually the html that is to be printed after everything is done. I do this because I want to be able to send headers at any stage in the process.
The first thing is to put the head together, then do whatever is needed. In this case check for valid login. The system detects that there is no valid login so a login screen should be added to the html-string. At the end the system appends a footer.
Here’s the code the controller goes over:
[code=php]
// Fire up the system
$system = new System;
$system->output .= file_get_contents(‘./application/templates/top.html’);
// Parse the config file
if ($config[‘sessions’]) {
Sessions::setSession();
if ($config[‘login’]) {
if (!isset($_SESSION[‘login’]) && $_SESSION[‘login’] != 1) {
$login = new Login;
$auth = $login->login();
if ($auth) {
$_SESSION[‘login’] = 1;
Router::redirect(__REF__.’/nl/’.$config[‘default_module’].’/’.$config[‘default_method’].’/0/index.html’);
} else {
Messenger::displayError($login->messages);
}
}
}
}
try {
$system->ignition();
} catch (Exception $e) {
echo ‘Caught exception: ‘, $e->getMessage(), “<br/>”;
}
$system->output .= file_get_contents(‘./application/templates/bottom.html’);
$system->display();
This function login() of the Login class is eventually called and it is supposed to add the html for the login box to the system variable $output. Therefore it calls $system->append(). I can see that the functions are all being called but somehow the html is not injected. Both the header and the footer are injected and displayed properly.
System function to add and display content:
[code=php]
function append($content) {
$this->output .= $content;
}
function display() {
echo $this->output;
}
Login function that adds html to the system class
[code=php]
public function displayLogin() {
$this->append(file_get_contents(‘./application/templates/login.html’));
}
So the problem that I don’t see the html in ‘./application/templates/login.html’ anywhere.