Welcome Guest, Not a member yet? Register   Sign In
Form Validation only Works When User is Logged In??
#11

[eluser]beemr[/eluser]
So, are you sending your error_string to the flashdata?

Then the problem can be isolated to your sessions, I think.

Have you tried using sessions->flashdata->keep_alive() (not sure I've remembered the method correctly) ? There might be an extra redirect in your structure that is garbage collecting your flash data before it gets displayed.
#12

[eluser]Tom Schlick[/eluser]
ok im gonna post the way things get processed through my files so you guys can see where im doing something wrong...

ok first file is dashboard.php... its a controller
Code:
<?php

class Dashboard extends Controller
{
        //Constructor
        function Dashboard()
        {
                parent::Controller();
                //Load the language file
                $this->lang->load('dashboard', $this->config->item('language_code'));
        }
        //Default function
        function index()
        {
                $this->session->set_flashdata('info', 'testing... testing...');
                $this->template_library->load('user/dashboard_stage.tpl', 'user', 'user/user_lr.tpl');
        }
    
}

?>


ok the next file is the template library. this is basically a function to load the smarty tags with smarty and render the output...
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Template_library
{
function load($stage, $tag_file = NULL, $lr = NULL)
{
$CI =& get_instance();
$CI->session->keep_flashdata('info');
if (file_exists(APPPATH.'tags/tags_global.php'))
{
include(APPPATH.'tags/tags_global.php');
log_message('debug', 'TAGS: Global Tags Loaded');
}
if($tag_file != NULL)
{
if(is_array($tag_file))
{
foreach ($tag_file as $name)
{
if (file_exists(APPPATH.'tags/tags_'.$name.'.php'))
{
include(APPPATH.'tags/tags_'.$name.'.php');
log_message('debug', 'TAGS: Tag File Tags Loaded');
}
}
}
else
{
if (file_exists(APPPATH.'tags/tags_'.$tag_file.'.php'))
{
include(APPPATH.'tags/tags_'.$tag_file.'.php');
log_message('debug', 'TAGS: Tag File Tags Loaded');
}
}
}
if(!isset($globals))
{
log_message('error', 'No Global Tags Available to Load - tags_global.php');
}
if(!isset($tags))
{
log_message('error', "No Global Tags Available to Load - $tag_file");
$tags = array('nothing' => '');
}
if($lr != NULL)
{
$globals['lr'] = $lr;
}
else
{
$globals['lr'] = 'template/lr_default.tpl';
}
$globals['stage'] = $stage;
$tags = array_merge($tags, $globals);
$CI->smartyextended->view('template/main', $tags);
}

[/code]
this file is one of the tags files so you can see how smarty takes in the variables
Code:
<?php

$base = "http://".$_SERVER['HTTP_HOST'];

//LOAD THE LINKS THAT ARE GLOBAL

$links['dashboard']                 = $base."/dashboard";
$links['login']                     = $base."/login";
$links['logout']                 = $base."/logout";

$tags['links'] = $links;

?>


the next file is my notice.tpl
Code:
{{if $session->flashdata('good')}}

    <div class="notice_green">{{$session->flashdata('good')}}</div>
    

{{elseif $session->flashdata('error')}}

    <div class="notice_yellow">{{$session->flashdata('error')}}</div>
    

{{elseif $session->flashdata('bad')}}

    <div class="notice_red">{{$session->flashdata('bad')}}</div>
    

{{elseif $session->flashdata('info')}}

    <div class="notice_blue">{{$session->flashdata('info')}}</div>
    
{{/if}}
#13

[eluser]beemr[/eluser]
[quote author="trs21219" date="1220492196"]
Code:
$CI->session->keep_flashdata('info');
[/quote]
Doesn't look like you are redirecting, so you probably don't need to keep the flashdata. That could be suppressing its output.
#14

[eluser]Tom Schlick[/eluser]
ya i just put that in to test to see if it was redirecting ... no difference
#15

[eluser]ontguy[/eluser]
Could you paste the login controller code?

What I've gathered so far:
- before you redirect you set the flashdata
- you're not able to access the flashdata from the redirected page (this is the problem)
#16

[eluser]drewbee[/eluser]
Can you set error reporting to E_ALL if you do not have it set already? Lets see if that kicks anything out to us.
#17

[eluser]Tom Schlick[/eluser]
ill get all of that info to you guys tonight when i have a chance to get back on... right now im doing this from my blackberry Smile
#18

[eluser]Tom Schlick[/eluser]
Login Controller:
Code:
&lt;?php

class Login extends Controller
{
    function _construct()
    {
        parent::Controller();
    }
    
    function index()
    {
        if($this->session->userdata('logged_in'))
        {
            redirect('dashboard');
        }
        if($this->input->post('username'))
        {
            $this->load->helper(array('form', 'url'));
            $this->load->library('validation');
            $this->validation->set_error_delimiters('<div class="notice_red">', '</div>');
            $rules['username']    = "required|trim|alpha_numeric|max_length[20]|xss_clean";
            $rules['password']    = "required|max_length[40]|xss_clean";
            $this->validation->set_rules($rules);
            
            if ($this->validation->run() == FALSE)
            {
                $this->template_library->load('user/login.tpl');
            }
            else
            {
                $username = $this->input->post('username');
                $password = $this->input->post('password');
                log_message('debug', 'username and information declared in login function');
                $this->user_library->doLogin($username, $password);
            }
        }
        else
        {
            $this->template_library->load('user/login.tpl');
        }
    }
}    
?&gt;
#19

[eluser]drewbee[/eluser]
I'm starting to think. I don't have access to CI's core right now. But the session data is updated at the end of a page run IE waiting for all changes to be made before updating the cookie/database.

I wonder if its possible that by putting that redirect in your page it doesn't give CI's core the ability to make that final session update?
#20

[eluser]ontguy[/eluser]
is there any output if you echo the flashdata in the login controller?




Theme © iAndrew 2016 - Forum software by © MyBB