Postingan

Menampilkan postingan dengan label codeigniter

Contekan controller validation form input di Codeigniter

 Berikut contekan untuk membuat validation form di controller codeigniter public function login () { $this -> load -> helper ( array ( 'form' , 'url' )); $this -> load -> library ( 'form_validation' ); //username,password -> adalah input dari view form $this -> form_validation -> set_rules ( 'username' , 'Username' , 'required' ); $this -> form_validation -> set_rules ( 'password' , 'Password' , 'required' ); if ( $this -> form_validation -> run () == FALSE ) { //script jika form tidak valid } else { //script jika form valid } }

Contekan Codeigniter Select2 Ajax

 Berikut ini merupakan contekan source code Select2 dengan Ajax PHP CSS dan JS Select2 < link href = "https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel = "stylesheet" /> < script src = "https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js" ></ script > *Butuh Jquery juga Script AJAX $ ( document ). ready ( function () { $ ( "#nim" ). select2 ({ placeholder: 'Pilih Data' , minimumInputLength: 4 , ajax: { url: " <?= base_url () ? > datauser" , dataType: 'json' , delay: 250 , data : function ( data ) { return { searchTerm: data . term // search term }; }, processResults : function ( response ) { return { results:response }; ...

Contekan jquery ajax php

Contoh Ajax JQuery Codeigniter dan Laravel Codeigniter url bisa diganti GET atau POST, tergantung kebutuhan < script >      $ ( '#form_kelola' ). submit ( function ( e ){          e . preventDefault ();          var   data  =  new   FormData ( document . getElementById ( 'form_kelola' ));          $ . ajax ({              url :   ' <?= base_url () ? > admin/save' ,              type:   'POST' ,              data:   data ,              contentType: false ,              processDat...

Contekan membuat helper di Codeigniter 3

Membuat helper di codeigniter 3 Buat file didalam folder application > helpers contoh : function_helper.php isinya : <?php   defined ( 'BASEPATH' ) OR  exit ( 'No direct script access allowed' ); if  (! function_exists ( 'userSession' )) {      function   userSession () {          $ci  = &   get_instance ();  //digunakan untuk memanggil function di codeigniter,                                  //misal session          return   $ci -> session -> userdata ();     } } Kemudian panggil/load di construct controller function   __construct () {  ...

Contekan .htaccess Codeigniter hilangin index.php

Cuma contekan .htaccess codeigniter untuk hilangin index.php diletakkan di root project codeigniter dengan nama file .htaccess <IfModule mod_rewrite.c> Options -Indexes <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$ 1 [L,R= 301 ] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> Maapin cuma dikit, namanya juga contekan