shakayu 0 Light Poster

Hello Guys, am actually working on a website...
I want a login on the top left corner...login..then when the user click on this ..a modal form would appear asking them for their user-name & password..
I have a already do the login form

controller

?php




   function index()

   {

  $data['main_content'] ='login_form';

  $this->load->view('includes/template', $data);



   }


  function validate_credentials()
    {       
        $this->load->model('Employee_model');

        $query = $this->Employee_model->validate();

        if($query) // if the user's credentials validated...
        {
            $data = array(
                'username' => $this->input->post('Username'),
                'is_logged_in' => true
            );

            $this->session->set_userdata($data);
            redirect('site/members_area');
        }
        else // incorrect username or password
        {
            $this->index();
        }
    }   


    function logout()
    {
        $this->session->sess_destroy();
        $this->index();
    }

}


*model*

<?php

class Employee_model extends CI_Model {


function validate()
    {
        $this->db->where('username', $this->input->post('Username'));
        $this->db->where('password', md5($this->input->post('Password')));
        $query = $this->db->get('employee');

        if($query->num_rows == 1)
        {
            return true;
        }

    }

    function register_employee($Type_ID, $First_Name, $Last_Name, $Gender, $Date_of_Birth, $Street, $Town, $Home, $Mobile, $Email_Address, $Job_Title, $Username, $Password, $Confirm_Password)
    {

    $query_str = "INSERT INTO employee(Type_ID, First_Name, Last_Name, Gender, Date_Of_Birth, Street, Town, Home, Mobile, Email_Address, Job_Title, Username, Password, Confirm_Password) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ; 

    $this->db->query($query_str,array($Type_ID, $First_Name, $Last_Name, $Gender, $Date_of_Birth, $Street, $Town, $Home, $Mobile, $Email_Address, $Job_Title, $Username, $Password, $Confirm_Password));

}


*view*

Login_area

</div>
    <h2>Welcome Back, <?php echo $this->session->userdata('username'); ?>!</h2>
     <p>This section represents the area that only logged in employers can access.</p>
    <h4><?php echo anchor('login/logout', 'Logout'); ?></h4>

</div>


Login_form.php
<div id="login_form">



            <h1>Log in !</h1>
    <?php 
    echo form_open('login/validate_credentials');

    echo form_input('Username', 'Username');
    echo form_password('Password', 'Password');
    echo form_submit('submit', 'Login');
    echo form_close();
    ?>


    </div>

Please guys help me...to display like a modal form on top...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.