Welcome Guest, Not a member yet? Register   Sign In
simple question - how to fix form validation errors
#1

[eluser]bill19[/eluser]
Hi everyone,

I am working with the ion_auth authorization library:

when my application is called, I would like it to to go to the login form:

Code:
<div class='mainInfo'>

<div class="pageTitle">Login</div>
    <div class="pageTitleBorder"></div>
<p>Please login with your email/username and password below.</p>

<div id="infoMessage">&lt;?php echo $message;?&gt;</div>

    &lt;?php echo form_open("auth/login");?&gt;
    
      <p>
       <label for="identity">Email/Username:</label>
       &lt;?php echo form_input($identity);?&gt;
      </p>
      
      <p>
       <label for="password">Password:</label>
       &lt;?php echo form_input($password);?&gt;
      </p>
      
      <p>
       <label for="remember">Remember Me:</label>
       &lt;?php echo form_checkbox('remember', '1', FALSE, 'id="remember"');?&gt;
   </p>
      
      
      <p>&lt;?php echo form_submit('submit', 'Login');?&gt;</p>

      
    &lt;?php echo form_close();?&gt;

    <p><a href="forgot_password">Forgot your password?</a></p>

</div>

my controller has in part the following code:

Code:
else
  {  //the user is not logging in so display the login page
   //set the flash data error message if there is one
                    
                        $this->data['message']='';
                        $this->data['identity']='';
                        $this->data['password']='';
                    
   $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');

   $this->data['identity'] = array('name' => 'identity',
    'id' => 'identity',
    'type' => 'text',
    'value' => $this->form_validation->set_value('identity'),
   );
   $this->data['password'] = array('name' => 'password',
    'id' => 'password',
    'type' => 'password',
   );

   $this->load->view('auth/login', $this->data);
  }
}

When I login I get the following output:

Quote:Login

Please login with your email/username and password below.
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: message

Filename: auth/login.php

Line Number: 7

Email/Username:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: identity

Filename: auth/login.php

Line Number: 13

Password:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: password

Filename: auth/login.php

Line Number: 18

I think what is happening, is that because the user has not logged in nothing is being passed by the controller to the view by $this->data. This then appears to cause a validation error. Is there a way to avoid this problem? I just want the form to load for login without any errors, but would like to keep validation in place.

Thanks in advance,

Bill




Theme © iAndrew 2016 - Forum software by © MyBB