0

Hello everyone.

I am trying to make a simple to-do list program using PHP and the MVC pattern. I have managed to make the login page, the model and the controller for managing logins. It is working properly because it can discern if the user exists or not. After validating the user, it includes another page using require_once(). The problem is that it is displaying the contents of the new page (the one you see after loggin in) right below the login form instead of simply replacing the whole page with the new one. Here is the code. It is located in the index.php page:

<?php

include 'model/user_model.php';
include 'controller/user_controller.php';
include 'view/user_view.php';


$usermodel = new UserModel();
$usercontroller = new UserController($usermodel);
$userview = new UserView($usercontroller, $usermodel);

if(!isset($_SESSION)) {
  $userview->outputlogin();
}

if(isset($_REQUEST['name'],$_REQUEST['password'])) {


    if ($usercontroller->validateuser($_REQUEST['name'],$_REQUEST['password'])) {

        $userview->outputlogged();

    }else {
        $userview->outputlogin();
        echo "<p>Wrong user or password</p>";
    }

}


?>

the outputlogged() function does this:

 public function outputlogged() {

        require_once($this->usermodel->template['logged']);
        }
}

It simply outputs the logged.php page which currently only says "You logged in". The problem is that the message is appearing BELOW the login form instead of simply replacing the whole page with the one with the message. What am I doing wrong?

2
Contributors
3
Replies
16
Views
2 Years
Discussion Span
Last Post by G_S
0

require parse the php code and add output not replace if you follow the flow of your code it may be right.

0

Small correction: disregard the last curly brace. It doesn't belong there (and I don't know how to edit my post anymore...)

0

Thanks for your response. Could do please be more specific? What do you mean by "require parse"? How do you add the content (could you please give me a snippet)??

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.