Welcome Guest, Not a member yet? Register   Sign In
Ion auth login form
#1

[eluser]malcomhfc[/eluser]
Hi there. Im a little new to php and codeigniter. Although i have background in other programming languages. Smile

I am using the Ion auth library and im making an admin panel for administrating my website.

I have the main controller admin which extends a core controller Admin_controller. - based on phil surdgens blog posts.

The Admin_controller checks for permissions etc in the admin panel. Im trying to make a login page. For example if not logged in then load function login()

but I cant seem to make a login form on my view work with
Code:
$this->ion_auth->login

I tried copying the login function from the example auth controller but it gave me errors
Quote:Message: Undefined variable: email

the view is:
Code:
<?php echo form_open("admin/login");?>
        
      <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;

i also tried

Code:
&lt;?php echo form_open('admin/login'); ?&gt;
            <ul>
                <li>
                    &lt;input type="text" name="email" value="Email" /&gt;
                </li>
                <li>
                    &lt;input type="password" name="password" value="Enter Password" /&gt;
                </li>
                &lt;input type="submit" name="submit" value="Login" /&gt;
            </ul>
        &lt;?php echo form_close(); ?&gt;

Any help on a simple login form which will run the admin/login function correctly please? Any help would be greatly appretiated Smile
#2

[eluser]Th3FalleN[/eluser]
I actually had the same exact problem 2 days ago, if you look at the example controller you'll notice it is passing the variables to the form, i myself didn't like that method so tweaked it to this.

Code:
echo form_open('admin/validate_credentials', array('class' => 'form col'));
    echo '<p>';
    echo form_label('Name:', 'username', array('class' => 'strong'));
    echo form_input(array('name' => 'username', 'tabindex' => '2', 'id' => 'Username', 'title' => 'Please enter your Username'), 'Username', 'onClick="this.value=\'\'"; onblur="this.value=!this.value?\'Username\':this.value;"');
    echo '</p><p>';
    echo form_label('Password:', 'password', array('class' => 'strong'));
    echo form_password(array('name' => 'password', 'tabindex' => '2', 'id' => 'Password', 'title' => 'Please enter your Password'), 'Password', 'onClick="this.value=\'\'"; onblur="this.value=!this.value?\'Password\':this.value;"');
    echo '</p>';
    echo form_button(array('name' => 'login', 'class' => 'small fr', 'type' => 'submit'), $this->lang->line('g_login'));
    echo form_close();

theres some extra code obviously because thats from my live controller, but that should give you what you need to use it correctly.
#3

[eluser]malcomhfc[/eluser]
I removed all the extra code and the form works. Thanks a lot Th3FalleN. Smile
#4

[eluser]Th3FalleN[/eluser]
No problem at all that auth system is pretty handy glad you could get it working.




Theme © iAndrew 2016 - Forum software by © MyBB