Login( after regester for data in codginetar with session);

controler====> 

public function login_form(){

$data['page_keywords'] = '';

$data['page_description'] = ''; $data['page_slug'] = 'business_plan'; $data['page_title'] = 'Business Plan'; if($this->session->userdata('is_customer_logged_in')){ redirect(base_url().'index.php/home_page'); } // print_r($this->session->userdata()); die(); if ($this->input->server('REQUEST_METHOD') === 'POST') { $this->form_validation->set_rules('email','email','required'); $this->form_validation->set_rules('password', 'password', 'required'); $email = $this->input->post('email'); $password =$this->input->post('password'); $valid = $this->customer_model->login_form($email,$password); //print_r($valid); //die(); if(count($valid)>0) { if($this->form_validation->run()==TRUE) { $data = array('name'=>$valid[0]['name'],'email'=>$valid[0]['email'], 'password'=>$valid[0]['password'], 'is_customer_logged_in' => true); $this->session->set_userdata($data); redirect('http://localhost/demoproject/deep/'); } } } $data['main_content'] = 'login_form'; $this->load->view('includes/front/front_template', $data); }

Views=====>

 <?php 

      //flash messages

      if($this->session->flashdata('flash_message')){

        if($this->session->flashdata('flash_message') == 'updated')

        {

          echo '<div class="alert alert-success">';

            echo '<a class="close" data-dismiss="alert">×</a>';

            echo '<strong>Well done!</strong> Registered successfully.';

          echo '</div>';       

        } else{

          echo '<div class="alert alert-danger">';

            echo '<a class="close" data-dismiss="alert">×</a>';

            echo '<strong>Oh snap!</strong> change a few things up and try submitting again.';

          echo '</div>';          

        }

      }

      ?>

<html lang="en-US">

  <head>

    <title></title>

    <meta charset="utf-8">

    <link href="<?php echo base_url(); ?>assets/css/global-admin.css" rel="stylesheet" type="text/css">

  </head>

  <body>

    <div class="container">

<div class="col-lg-12 register-form">

<div class="clearfix"></div>

  <?php  

if(isset($message_error) && $message_error){

  echo '<br><div class="alert alert-danger">';

echo '<a class="close" data-dismiss="alert">×</a>';

echo '<strong>Error!</strong> email or password is wrong.';

  echo '</div>';             

  }


if(isset($message_error_pending) && $message_error_pending){

          echo '<br><div class="alert alert-danger">';

            echo '<a class="close" data-dismiss="alert">×</a>';

            echo '<strong>Error!</strong> your email confirmation is not complete.';

          echo '</div>';             

      }

  if($this->session->flashdata('register') && $this->session->flashdata('register')=='true'){

             $this->session->set_flashdata('register', 'false'); 

          echo '<br><div class="alert alert-success">';

            echo '<a class="close" data-dismiss="alert">×</a>';

            echo 'Register successfully please login now.';

            //echo 'Check your email inbox/spam and click the link given in email to verify your account.';

          echo '</div>';             

      }

?>

<?php echo validation_errors(); ?>

<div class="clearfix"></div>

<?php

      $attributes = array('class' => 'col-sm-6 col-sm-offset-3');

      echo form_open('', $attributes);

?>

      <h4 class="text-center">Login form</h4>

<input type="email" required value="<?php if($this->input->post('email')!='') { echo $this->input->post('email'); } ?>" class="form-control" name="email" placeholder="Email">

  <br>

<input type="password" value="" class="form-control" name="password" placeholder="Password">

      <br />

 <div class="col-sm-6 lik">

<a href="<?php echo base_url(); ?>index.php/form">Register</a><br>

<!--a href="#">Resend Verification Link</a-->

</div>

 <div class="col-sm-6 text-right"><input type="submit" value="Login" class="btn btn-large btn-primary" name="submit"></div> 

<?php 

      echo form_close();

      ?>      


    </div> 

</div><!--container-->

  </body>

</html>

Model===>

      function login_form($email,$password)  

      { 

$this->db->select('*');

$this->db->from('form');

$this->db->where('email', $email);  

        $this->db->where('password',md5($password)); 

$query = $this->db->get();

return $query->result_array();   

      } 

Comments

Popular posts from this blog

condition in table data for html

my notepad code notes

React.js Notes