Selasa, 02 Januari 2018

Cara Membuat Server Side untuk Admin

Saya membuat server side bagian admin. Dibawah ini cara-caranya :

1. Buat view login.operator.php
Script :

<!DOCTYPE html>
<html >
<head>
  <meta charset="UTF-8">
  <title>Silahkan Login</title>
 
 

 
      <link rel="stylesheet" href="<?php echo base_url ();?>css/style2.css">

 
</head>

<body>


<form method="POST" action="<?php echo base_url ();?>masuk_operator/getlogin_operator"
onsubmit="return cekform();">


  <div class="container">
  <div class="login">
  <h1 class="login-heading">
      <strong>Selamat Datang Admin Natasha</strong</h1>
      <form method="post">
        <input type="text" name="username" placeholder="Username" required="required" class="input-txt" />
          <input type="password" name="password" placeholder="Password" required="required" class="input-txt" />
          <div class="login-footer">
             <a href="#" class="lnk">
              <img src="<?php echo base_url ();?>img/lg.png" width="150" height="60" alt="" />
            </a>
            <button type="submit" class="btn btn--right">MASUK  </button>
   
          </div>
      </form>

      <?php echo $this->session->flashdata('pesan');?>
     
  </div>
</div>
 
    <script src="<?php echo base_url ();?>js/index.js"></script>

</body>
</html>


2. Tampilan


3. Modelnya
security_login.php

<?php
class Security_login extends CI_Model {

//get secutiry untuk akses halaman admin
public function getsecurity()
{
$username = $this->session->userdata('username');
if(empty($username))
{
$this->session->sess_destroy();
redirect('masuk_admin');
}

}
}

4. Controller

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Masuk_admin extends CI_Controller {

    public function index() {
        $this->load->view('v_login_admin');
    }

    public function getlogin() {
        $user = $this->input->post('username');
        $this->session->set_userdata('session_user_admin', $user);
        $u = $user;
        $p = $this->input->post('password');
        $this->load->model('model_data');
        $this->model_data->getlogin($u, $p);
    }

}



0 komentar:

Posting Komentar