Kamis, 14 April 2016

Starting CodeIgniter

1. INSTALLATION
 a. Download CodeIgniter 3.0

 b. Ekstrak file di folder htdocs di XAMPP
c. Ubah base_url pada file application/config/config.php di folder codeigniter anda menjadi lokasi folder anda
d. Buka file dalam application/config/database.php di folder codeigniter dan ubah menjadi di bawah :

$db['default'] = array(  
      'dsn'     => '',  
      'hostname' => 'localhost',          //BIARKAN BILA MEMANG ADA DI LOCALHOST  
      'username' => 'root',                         //MASUKKAN USER PADA PHPMYADMIN ANDA  
      'password' => '',                                   //MASUKKAN PASSWORD USER BILA ADA  
      'database' => 'cobaci',               //MASUKKAN NAMA DATABASE ANDA  
      'dbdriver' => 'mysqli',                    //MASUKKAN JENIS SOFTWARE DATABASE ANDA  
      'dbprefix' => '',  
      'pconnect' => FALSE,  
      'db_debug' => (ENVIRONMENT !== 'production'),  
      'cache_on' => FALSE,  
      'cachedir' => '',  
      'char_set' => 'utf8',  
      'dbcollat' => 'utf8_general_ci',  
      'swap_pre' => '',  
      'encrypt' => FALSE,  
      'compress' => FALSE,  
      'stricton' => FALSE,  
      'failover' => array(),  
      'save_queries' => TRUE  
 );  

 Selesai! CodeIgniter Anda sekarang dapat digunakan

2. MAKING A "HELLO WORLD"

Kali ini kita akan mencoba menampilkan sebuah pesan hello world menggunakan code igniter. Langkah-langkahnya sebagai berikut
a. Buatlah file hello_world.php di folder views
b. Isi sebagai berikut :

<?php  
 defined('BASEPATH') OR exit('No direct script access allowed');  
 ?><!DOCTYPE html>  
 <html lang="en">  
 <head>  
      <meta charset="utf-8">  
      <title>Welcome codeig</title>  
      <style type="text/css">  
      ::selection { background-color: #E13300; color: white; }  
      ::-moz-selection { background-color: #E13300; color: white; }  
      body {  
           background-color: #fff;  
           margin: 40px;  
           font: 13px/20px normal Helvetica, Arial, sans-serif;  
           color: #4F5155;  
      }  
      a {  
           color: #003399;  
           background-color: transparent;  
           font-weight: normal;  
      }  
      h1 {  
           color: #444;  
           background-color: transparent;  
           border-bottom: 1px solid #D0D0D0;  
           font-size: 19px;  
           font-weight: normal;  
           margin: 0 0 14px 0;  
           padding: 14px 15px 10px 15px;  
      }  
      code {  
           font-family: Consolas, Monaco, Courier New, Courier, monospace;  
           font-size: 12px;  
           background-color: #f9f9f9;  
           border: 1px solid #D0D0D0;  
           color: #002166;  
           display: block;  
           margin: 14px 0 14px 0;  
           padding: 12px 10px 12px 10px;  
      }  
      #body {  
           margin: 0 15px 0 15px;  
      }  
      p.footer {  
           text-align: right;  
           font-size: 11px;  
           border-top: 1px solid #D0D0D0;  
           line-height: 32px;  
           padding: 0 10px 0 10px;  
           margin: 20px 0 0 0;  
      }  
      #container {  
           margin: 10px;  
           border: 1px solid #D0D0D0;  
           box-shadow: 0 0 8px #D0D0D0;  
      }  
      </style>  
 </head>  
 <body>  
 <div id="container">  
      <h1>Hello World</h1>  
   <p>Welcome to my very own Welcome Page!!</p>  
      <p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds. <?php echo (ENVIRONMENT === 'development') ? 'CodeIgniter Version <strong>' . CI_VERSION . '</strong>' : '' ?></p>  
 </div>  
 </body>    
 </html>  

c. Kemudian pada file welcome.php di folder controllers, isi sebagai berikut :

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

d. Hasilnya dapat dibuka melalui browser

 3. MAKE A "PHONEBOOK DATABASE"
Kali ini kita akan menampilkan suatu tabel yang berisi list nomor telepon yang diambil dari database

a. Buatlah file tampil.php di folder Controllers, isikan sebagai berikut

 <?php  
  class Tampil extends CI_Controller{  
   function __construct(){  
    parent::__construct();  
    $this->load->helper(array('url', 'form'));  
    $this->load->model('m_tampil');  
   }  
   function lihat(){  
    $data['data_buku'] = $this->m_tampil->m_lihat();  
    $this->load->view('v_lihat', $data);  
   }  
  }  
 ?>  

b. Buatlah file m_tampil.php di folder Models, isikan sebagai berikut

<?php  
  class M_tampil extends CI_Model{  
   function __construct(){  
    parent::__construct();  
    $this->load->database();  
   }  
   function m_lihat(){  
    $lihat = $this->db->get('phonebook');  
    return $lihat->result();  
   }  
  }  
  ?>  

c. Buatlah file v_lihat.php di folder Views


 <!DOCTYPE html>  
 <html>  
  <head>  
   <title>PhoneBook</title>  
  </head>  
  <body>  
   <h1>My Phonebook</h1>  
   <table border="1">  
    <tr>  
     <th>No</th>  
     <th>Nama</th>  
     <th>Telp</th>  
    </tr>  
    <?php foreach ($data_buku as $lihat){  
     ?>  
    <tr>  
     <td><?php echo $lihat->no; ?></td>  
     <td><?php echo $lihat->nama; ?></td>  
     <td><?php echo $lihat->telp; ?></td>   
    </tr>  
    <?php   
    }  
    ?>  
   </table>  
  </body>  
  </html> 

d. Buka melalui browser, maka akan ditampilkan sebagai berikut :

Jumat, 01 April 2016

Visit stickmypride.com , It's free and always be

SOAL 1 :

Kunjungi web kami stickmypride.com , di dalamnya merupakan kios stiker dengan desain-desain kreatif (saat ini web masih under-construction).

Biaya pembuatan web ini adalah Rp.434.280.000 dengan rincian sebagai berikut
    Hosting Unlimited : Rp.394.800 (32.900/bulan)
    Domain "stickmypride" : Rp 0- (gratis dari hostingnya)
    PPn 10% : Rp.39.480

Fitur pada web ini, customer dapat melakukan registrasi (sign-in) dan menjadi member dari kami. Akan ada diskon spesial khusus member


 
Selain sign-in tentu saja terdapat fitur login


 Di dalam web ini, terdapat pula fitur berupa sub-beranda yang menampilkan desain stiker yang paling diminati pengunjung (semacam rekomendasi untuk customer)


SOAL 2 :

a) Membuat script untuk koneksi.php

<?php  
      $host = 'localhost';  
      $username = 'root';  
      $password = '';  
      $database = 'tesdb';  
      $connection = mysqli_connect($host, $username, $password, $database);  
      if(!$connection)  
      {  
           echo"koneksi gagal ";  
      }  
      else echo "Connected Succesfully";   
 ?> 

Hasilnya sebagai berikut :


b) Membuat script untuk login.php

 <!DOCTYPE htnml>   
  <html>   
  <head>   
    <title>   
       Halaman Login   
    </title>   
  </head>   
  <body>   
    <form action="" method="post">   
       Username : <input id="name" name="username"><br>   
       Password : <input id="password" name="password"><br>   
       <input type="submit" value="Login">        
    </form>   
  </body>   

Hasilnya sebagai berikut :



c) Membuat Script untuk menampilkan data di dalam tabel praktikum

<?php   
  include'indeks.php';    
  $i=1;    
  echo '<table border="1" style="background-colour:orange">    
    <thead><td> No. </td><td> Kode </td><td> Mata Praktikum </td><td> Jumlah Praktikan</td></thead><tbody>';    
    echo '<h1> Data Mata Praktikum dan Jumlah Praktikan </h1>';    
    if($resultc = $connection->query("select * from `praktikum`")){    
     while($rowc = $resultc->fetch_assoc()) {    
      echo '<tr>';    
      echo '<td>', $i++, '</td>';    
      echo '<td>', $rowc['kode_mk'],'</td>';    
      echo '<td>', $rowc['nama_mk'],'</td>';    
      echo '<td>', $rowc['jumlah_praktikan'],'</td>';    
     echo '</tr>';    
     }    
     $resultc->free();    
    }    
    echo '</tbody></table>';    
    echo '<div style="text-align:center"><button> Tambah Data MK </button></div>';    
  ?>    

Hasilnya sebagai berikut :