Welcome Guest, Not a member yet? Register   Sign In
load->view() problem
#1

[eluser]Mysticsage[/eluser]
I have everything working so far except I seem to have a problem with one method where $this->load->view() does not work.

It's a simple function to check if the user has submitted a username and password and then set session variables to be used later on.

Here is the part that does not seem to want to work:
Code:
$username = $this->input->post('username');
$password = $this->input->post('password');
        
    if (!$username) {
        $this->load->view('error.php');
    }
(note that I have tried !$username, $username == false and $username === false)

edit: I have also checked to see if the if statement is working by putting exit('asdf') in


the code for error.php is just a generic error page
Code:
<p>Sorry, there was an error with your request. Please try again later.</p>

Am I doing something wrong?


Any help would be appreciated,
Mystic
#2

[eluser]designfellow[/eluser]
Hi,

You can try this & it will work
Code:
if (!isset($username))
    {
        $this->load->view('main/error.php');
    }

Also, you can skip .php extensions when calling views

Happy Coding,
DesignFellow
#3

[eluser]Mysticsage[/eluser]
I tried that, and unfortunately it's still not working.

The problem isn't that the if statement isn't working ("I have also checked to see if the if statement is working"), the problem is that load->view() doesn't work

edit: that cheat sheet in your signature is going to be very helpful.. Glad I decided to take a look at it
#4

[eluser]Mysticsage[/eluser]
I fixed it.. somewhat..
I still couldn't get load->view() to work for the life of me so I just did it manually
Code:
$message = 'You can not access the login page directly';
include('/system/application/views/header.php');
include('/system/application/views/flash.php');
include('/system/application/views/footer.php');
(there is a variable for message in flash.php)




Theme © iAndrew 2016 - Forum software by © MyBB