I’m working on a project for a class i’m taking. Right now i’m stuck on my login script. When logging in (with a valid or invalid user/pass) it attempts to login but it can’t find Template.php. But if i add a set_include_path for template or an exact url to template the login will work but the logout continues to throw a similar error.
Any suggestions would be appreciated.
Example Webpage (Without set_include_path() in login.php):
[url]http://babbage.cs.missouri.edu/~bar338/webProject/index.php
Example Webpage (WITH set_include_path() in login.php):
[url]http://babbage.cs.missouri.edu/~bar338/test/webProject/index.php
You can login using the username: test Password: pass
But if you enter an invalid username/pass the error below happens.
Brief File Structure
[QUOTE]
Index.php
login.php
System (Folder)
—-Template.php
—-RedirectBrowserException.php
Error Message:
[QUOTE]
Warning: require_once(Template.php) [function.require-once]: failed to open stream: No such file or directory in /students/b/bar338/public_html/webProject/login.php on line 2
Fatal error: require_once() [function.require]: Failed opening required ‘Template.php’ (include_path=’.:/usr/share/pear:/usr/share/php’) in /students/b/bar338/public_html/webProject/login.php on line 2
Files (let me know if you need more)
Index.php
[code=php]<?php
// this creates the home page
// tell php what directories to search when doing include and require
$paths = ‘system’ . PATH_SEPARATOR . ‘components’ . PATH_SEPARATOR . ‘templates’;
set_include_path($paths);
require_once(‘Template.php’);
require_once(‘Page.php’);
// do any processing of application first
// create components and run them
$page = new Page(‘Home’);
$page->run(array(‘uname’ => ‘Kevin’, ‘id’ => ’22’));
// create this application’s content
$tmpl = new Template();
$html = $tmpl->build(‘maincol.html’);
$css = $tmpl->build(‘maincol.css’);
$mainContent = array(array(‘html’=>$html, ‘css’=>$css));
$html = $tmpl->build(‘login.html’);
$css = $tmpl->build(‘login.css’);
$html2 = $tmpl->build(‘options.html’);
$css2 = $tmpl->build(‘options.css’);
$sideContent = array(array(‘html’=>$html, ‘css’=>$css), array(‘html’=>$html2, ‘css’=>$css2));
// create the page
print $page->build($mainContent, $sideContent);
?>
Login.php
[code=php]<?php
require_once(‘Template.php’);
require_once(‘RedirectBrowserException.php’);
$action = empty($_POST[‘action’]) ? ” : $_POST[‘action’];
if ($action == ‘do_login’) {
handle_login();
} else {
login_form();
}
function handle_login() {
$username = empty($_POST[‘username’]) ? ” : $_POST[‘username’];
$password = empty($_POST[‘password’]) ? ” : $_POST[‘password’];
if ($username == “test” && $password == “pass”) {
setcookie(‘username’, $username);
throw new RedirectBrowserException(‘memberhome.php’);
} else {
$error = ‘Incorrect Username/Password.’;
$tmpl = new Template();
$tmpl->error = $error;
$tmpl->username = $username;
print $tmpl->build(‘index.php’);
}
}
function login_form() {
$tmpl = new Template();
print $tmpl->build(‘index.php’);
}
?>