Welcome Guest, Not a member yet? Register   Sign In
Help loading a different view after validating login
#1

[eluser]DZlobins[/eluser]
Hey guys,

I'm fairly new to CodeIgniter and I've been having a small issue I can't seem to solve.

I have a page for a user to register an account, and if they make an error, instead of reloading the view, a new view loads UNDER the current one. Here is some pseudo code that handles this

if ($this->form_validation->run() == FALSE)
{
// validation didn't work, show the register view again
$this->load->view('register');

}

the else portion works

Is there a reload view function?
#2

[eluser]InsiteFX[/eluser]
Try this.

Code:
redirect('register', 'refresh');

Enjoy
InsiteFX
#3

[eluser]DZlobins[/eluser]
[quote author="InsiteFX" date="1254980990"]Try this.

Code:
redirct('register', 'refresh');

Enjoy
InsiteFX[/quote]

Hey, thanks for you help. I tried putting that in and instead I get:

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/system/application/views/header.php:15)

Filename: helpers/url_helper.php

Line Number: 539
#4

[eluser]joeizang[/eluser]
Quote:redirct('register', 'refresh');

try this, atleast it works in my current project:

<?php


redirect('controller/function');

?>
in that function you explicitly handle the login(including showing the loginpage). The error you are getting is like the session has been set already which is reason for the headers. so just close your browser and open a fresh window so you can start. Worst case use ob_flush() or something like that. check your php manual(very useful when developing).
#5

[eluser]InsiteFX[/eluser]
I need a new keboard LOL drops characters on me

It should be redirect

That error is usally a space after the opening or closing php tags.
#6

[eluser]DZlobins[/eluser]
Thanks for yourhelp guys but so far none of this worked. Only new errors are thrown
#7

[eluser]Unknown[/eluser]
Back to your original problem, you mentioned the else portion works meaning that the else condition is always executed? The code you have to the load the register view again is correct but perhaps your conditional is wrong in your "if" statement?

I would guess you need to check your validation rules to make sure your tests are correct with your form.

Regards




Theme © iAndrew 2016 - Forum software by © MyBB