Welcome Guest, Not a member yet? Register   Sign In
view does not load
#1

[eluser]Kenan[/eluser]
hi people, i have such a code (i have copied just the related part):

Code:
class Reg extends CI_Controller {
    
    public function __construct() {
        parent::__construct();
    }
    
    public function reg_form() {
        if ($this->session->userdata('id')) {
            if ($this->input->server('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest') {
                exit();
            }
            
            header('Location: /');
        }
        else {
            if ($this->input->server('HTTP_X_REQUESTED_WITH') != 'XMLHttpRequest') {
                header('Location: /');
                exit();
            }
            
            $this->load->view('az/reg/reg');
        }
    }
    
    public function auth_form() {
        if ($this->session->userdata('id')) {
            if ($this->input->server('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest') {
                exit();
            }
            
            header('Location: /');
        }
        else {
            if ($this->input->server('HTTP_X_REQUESTED_WITH') != 'XMLHttpRequest') {
                header('Location: /');
                exit();
            }
            
            $this->load->view('az/reg/auth');
        }
    }
    
    public function register() {
        if (!$this->input->post()) {
            if ($this->session->userdata('id')) {
                $this->load->view('az/msgs/logged_in');
                exit('smth to test..');
            }
            else {
                header('Location: /');
                exit();
            }
        }
    
    // and so on..
    
    }
}

the p. functions reg_form() n auth_form() work perfectly n load the view as it should be done, the p. function register() also works perfectly, BUT it does not load the view, just displays the content of the function exit(), any ideas?
#2

[eluser]CroNiX[/eluser]
Try removing the exit right after loading the view. You're not allowing CI to finish.
#3

[eluser]Kenan[/eluser]
[quote author="CroNiX" date="1404914458"]Try removing the exit right after loading the view. You're not allowing CI to finish.[/quote]

i have tried but useless, the result is just white empty page
#4

[eluser]CroNiX[/eluser]
That typically indicates a PHP error but you are suppressing them. Check your PHP error log, CI error log or enable display_errors.
#5

[eluser]Kenan[/eluser]
[quote author="CroNiX" date="1404916538"]That typically indicates a PHP error but you are suppressing them. Check your PHP error log, CI error log or enable display_errors.[/quote]

there is no errors, all errors enable to be displayed but no result
#6

[eluser]joergy[/eluser]
Probably the problem is hidden in Your last "// and so on.."

Try to use "return;" after Your loading of the view, if it's necessary "to exit"...
#7

[eluser]Tim Brownlaw[/eluser]
Time to do some debug... You need to test that you code is working...

For starters...
For those exits() not preceded by a header(...) add in some text - like exit('Hit the Exit on '.__LINE__) which should showif it's hitting one of those.

AND are you sure you don't want to use return; in those instances! Without seeing the rest of your code, I have no clue what's going on.

But start digging through what you have and see where it does get to ( using debug messages... even echo statements like "Hi I got here". __FILE__ . ' at '__LINE__ ) and track back to where it stops working.
#8

[eluser]Kenan[/eluser]
[quote author="Tim Brownlaw" date="1405049595"]Time to do some debug... You need to test that you code is working...

For starters...
For those exits() not preceded by a header(...) add in some text - like exit('Hit the Exit on '.__LINE__) which should showif it's hitting one of those.

AND are you sure you don't want to use return; in those instances! Without seeing the rest of your code, I have no clue what's going on.

But start digging through what you have and see where it does get to ( using debug messages... even echo statements like "Hi I got here". __FILE__ . ' at '__LINE__ ) and track back to where it stops working.[/quote]

thanks a lot! the way with return can help




Theme © iAndrew 2016 - Forum software by © MyBB