This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Minggu, 22 Desember 2019

scrip view backend v_pelanggan read

<a href="<?php echo site_url('pelanggan/create');?>">
  <button type="button">tambah</button>
</a><br>
<table border="1" width="50%">
  <tr>
    <th>No</th>
    <th>Nama</th>
    <th>Alamat</th>
    <th>No_Tlp</th>
    <th>Email </th>
    <th>Password</th>
  </tr>
  <?php
  $no=1;
  foreach ($data->result_array() as $row) {
   ?>
  <tr>
    <td><?php echo $no ?></td>

    <td><?php echo $row['nama_pelanggan']?></td>
    <td><?php echo $row['alamat']?></td>
    <td><?php echo $row['no_tlp']?></td>
    <td><?php echo $row['email_pelanggan']?></td>
    <td><?php echo $row['pswd_pelanggan']?></td>



  </tr>
  <?php
  $no++;
  }
  ?>
</table>

scrip view backend v_pelanggan create

<form class="" action="<?php echo site_url('pelanggan/save');?>" method="post">

  <?php echo $judul; ?><p></p>

  <label>Nama</label><br>
  <input type="text" name="nama_pelanggan" value="" placeholder="Masukan Nama Lengkap"><p></p>

  <label>Alamat</label><br>
  <input type="text" name="alamat" value="" placeholder="Masukan alamat"><p></p>

  <label>No_Tlp</label><br>
  <input type="text" name="no_tlp" value="" placeholder="Masukan No_Tlp"><p></p>

  <label>Email </label><br>
  <input type="text" name="email_pelanggan" value="" placeholder="Masukan Email Lengkap"><p></p>

  <label>password</label><br>
  <input type="text" name="pswd_pelanggan" value="" placeholder="Masukan Password"><p></p>


  <button type="submit">Simpan</button>
  <a href="<?php echo site_url('pelanggan');?>"> <button type="button" name="button">Batal</button> </a>
</form>

scrip model M_pelanggan

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

class M_pelanggan extends CI_Model{
  private $table='pelanggan';
  private $pk='id_pelanggan';

  public function GetAll()
  {
    $this->db->order_by($this->pk);
    return $this->db->get($this->table);
  }

  public function save($data)
  {

    return $this->db->insert($this->table, $data);
  }

}

scrip controller pelanggan

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

class Pelanggan extends CI_Controller{
private $folderview ="backend/v_pelanggan/";
//private $template ="backend/v_template/";
private $redirect ="pelanggan";

  public function __construct()
  {
    parent::__construct();
    $this->load->model('M_pelanggan');
    //Codeigniter : Write Less Do More
  }

  function index()
  {
    $q=$this->M_pelanggan->GetAll();
    $data=array(
    'judul'=>"Data pelanggan",
    'data'=>$q
  );
  //n$this->load->view($this->template.'menu',$data);
  $this->load->view($this->folderview.'read',$data);
  }
  public function create()
  {
    $data = array(
      'judul'=>'Daftar pelanggan Baru',
      'data' => ''
    );
    $this->load->view($this->folderview.'create',$data);
  }

  public function save()
  {
    $data = array(

      'nama_pelanggan'=> $this->input->post('nama_pelanggan'),
      'alamat'=> $this->input->post('alamat'),
      'no_tlp'=> $this->input->post('no_tlp'),
      'email_pelanggan'=> $this->input->post('email_pelanggan'),
      'pswd_pelanggan'=>md5($this->input->post('pswd_pelanggan'))
  );
  $this->M_pelanggan->save($data);
  redirect($this->redirect, 'refresh');

  }

}