Welcome Guest, Not a member yet? Register   Sign In
Problem with Login in HTML
#1

[eluser]Zimooon[/eluser]
Hi guys,

I use the Ion-Auth Admin tool. Now i did the login in html for a better look.
This is the Controller :
Code:
function login()
    {
        $this->data['title'] = "Login";

        //validate form input
        $this->form_validation->set_rules('email', 'Email Address', 'required|valid_email');
        $this->form_validation->set_rules('password', 'Password', 'required');

        if ($this->form_validation->run() == true)
        { //check to see if the user is logging in
            //check for "remember me"
            $remember = (bool) $this->input->post('remember');

            if ($this->ion_auth->login($this->input->post('email'), $this->input->post('password'), $remember))
            { //if the login is successful
                //redirect them back to the home page
                $this->session->set_flashdata('message', $this->ion_auth->messages());
                redirect('auth', 'refresh');
            }
            else
            { //if the login was un-successful
                //redirect them back to the login page
                $this->session->set_flashdata('message', $this->ion_auth->errors());
                redirect('auth/login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
            }
        }
        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'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');

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

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

Here is the login in php(this works)
Code:
<div class='mainInfo'>

    <div class="pageTitle">Login</div>
    <div class="pageTitleBorder"></div>
    <p>Please login with your email address and password below.</p>
    
    <div id="infoMessage">&lt;?php echo $message;?&gt;</div>
    
    &lt;?php echo form_open("auth/login");?&gt;
        
      <p>
          <label for="email">Email:</label>
          &lt;?php echo form_input($email);?&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);?&gt;
      </p>
      
      
      <p>&lt;?php echo form_submit('submit', 'Login');?&gt;</p>

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

</div>

And here is the code i wrote in html:
Code:
&lt;?php
    include('inc/inc-html-admin-start.php');
?&gt;
              <a name="anchorContent"></a>
                <div id="content" class="adminLogin">
                    <h1>Anmeldung</h1>                  
                    &lt;form action="auth/login/" method="post"&gt;
                              <fieldset>
                        <label for="email">Emailadresse:</label>
                        &lt;input type="text" id="email" name="email" value="" class="inputText" /&gt;
                      </fieldset>
                      <fieldset>
                        <label for="password">Passwort:</label>
                        &lt;input type="password" id="password" name="password" value="" class="inputText" /&gt;
                      </fieldset>
                      <fieldset>
                        &lt;input type="submit" id="login" name="login" value="Anmelden" /&gt;
                      </fieldset>
                    &lt;/form&gt;
                  </div>
                  </div>
  
&lt;?php
    include('inc/inc-html-admin-end.php');
?&gt;

But when i submit i get redirected to the page and NOT logged in Sad
any1 got an idea?

best regards
#2

[eluser]Nairobi[/eluser]
It might be because your form (new HTML) omits Remember and therefore doesn't set it (neither true nor false), but after email / password are validated, the error in calling (bool) on the unset Remember may be bumping you to the re-display loop.

I also prettified the HTML, but kept this:
Code:
<label for="remember">Remember Me:</label>
&lt;?php echo form_checkbox('remember', '1', FALSE);?&gt;

Edited to add: I tried your code as-is in a test site with ion_auth that I have, and had no problems logging in. Are you certain the credentials you're using are correct (silly question, but still...) ? Also, try putting the infoMessage back in to see if any messages are returned:
Code:
<div id="infoMessage">&lt;?php echo $message;?&gt;</div>




Theme © iAndrew 2016 - Forum software by © MyBB