Welcome Guest, Not a member yet? Register   Sign In
Codeigniter - Indonesia Community
#48
Thumbs Up 

Halo, salam kenal gan. Ane pendatang baru di framework CI ini.
Mohon kerjasamanya yah.


(06-10-2015, 03:28 AM)watarujunior Wrote: gan sepu, ane mau tanya nih. newbie thing.
Saya mau buat sebuah form dengan CI.
satu input form, yang mana nanti nilainya akan dikirim ke controller, jika valuenya sama dengan "abc123" makan akan meload view a, jika tidak akan kembali ke view form sebelumnya.

view form ane kira2 begini (form.php) :









PHP Code:
<?php echo form_open('kode'); ?>
    <div class="label">
          <input type="password" size="20" id="kode" name="kode"/>
    </div>
    
     <div class="label">
    <input type="submit" value="Kirim"/>
    </div>
    </form> 

nah controller ane buat begini (kode.php) :








PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Kode extends CI_Controller {

 function 
__construct()
 {
 
  parent::__construct();
 
  $this->load->helper('url');
 
  $this->load->helper('security');
 
  $this->load->helper('form');
 }
 
   
function index() {
 
       if ($this->input->post('submit')==true) {
 
       $data $this->input->post('kode');
 
       if($data != "abc123"){
 
            $this->load->view('form');
 
       }
 
       else
        
{
 
           $this->load->view('a');
 
              
 
}
}



ane ga dapatkan hasil apa2 hanya sebuah halaman kosong dengan address
base_url()/index.php/kode

mohon pencerahannya master sekalian. cuma skrip simple tapi membuat saya bingung....

terima kasih.


Oh, iya untuk agan wataru, coba skrip indexnya controller kode.php dirubah jadi begini 
PHP Code:
<?php 
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Kode extends CI_Controller {

 
 function __construct()
 
 {
 
   parent::__construct();
 
   $this->load->helper('url');
 
   $this->load->helper('security');
 
   $this->load->helper('form');
 
 }
 
   
  function index
() {
 
       if ($this->input->post('submit')==true) { /* setelah melakukan submit */
 
           $data $this->input->post('kode');
 
           if($data != "abc123"){
 
             $this->load->view('form');
 
           }
 
           else
            
{
 
             $this->load->view('a');
 
                  
        
}
 
       else /* sebelum melakukan submit */
 
       {
 
            $this->load->view('form');
 
       
 
 }


View tidak muncul (kosong) karena agan memberi kondisi post ( $this->input->post() ) pada awal fungsi, jadi kondisi sebelum post itu juga di beri else untuk view yang di tampilkan sebelum di submit. Semoga membantu gan.
a.k.a AriefNetwork Big Grin
Reply


Messages In This Thread
RE: Codeigniter - Indonesia Community - by antoub - 12-22-2014, 10:57 AM
RE: Codeigniter - Indonesia Community - by ridho - 01-03-2015, 03:51 AM
RE: Codeigniter - Indonesia Community - by twonno - 12-07-2016, 08:03 PM
RE: Codeigniter - Indonesia Community - by cakka - 01-23-2015, 06:43 AM
halo - by algenza - 01-28-2015, 11:49 PM
RE: Codeigniter - Indonesia Community - by andgaa - 02-04-2015, 09:51 PM
RE: Codeigniter - Indonesia Community - by Ferry - 02-06-2015, 11:28 AM
RE: Codeigniter - Indonesia Community - by s4if - 02-08-2015, 05:14 AM
RE: Codeigniter - Indonesia Community - by cakka - 02-24-2015, 09:45 PM
RE: Codeigniter - Indonesia Community - by dotphp - 03-07-2015, 06:15 PM
RE: Codeigniter - Indonesia Community - by freddy - 03-09-2015, 02:18 AM
RE: Codeigniter - Indonesia Community - by khalim - 03-21-2015, 12:22 AM
RE: Codeigniter - Indonesia Community - by Iman - 04-01-2015, 07:29 AM
RE: Codeigniter - Indonesia Community - by hotben - 04-02-2015, 03:06 AM
RE: Codeigniter - Indonesia Community - by tirta - 04-23-2015, 11:16 PM
RE: Codeigniter - Indonesia Community - by H4nk - 06-01-2015, 12:42 PM
RE: Codeigniter - Indonesia Community - by jureks - 06-04-2015, 11:23 PM
RE: Codeigniter - Indonesia Community - by AriefNetwork - 07-28-2015, 05:24 AM
RE: Codeigniter - Indonesia Community - by dv23 - 08-04-2015, 01:13 AM
RE: Codeigniter - Indonesia Community - by dv23 - 08-04-2015, 01:15 AM
RE: Codeigniter - Indonesia Community - by lomri - 08-09-2015, 02:48 AM
RE: Codeigniter - Indonesia Community - by tegs88 - 09-08-2015, 01:23 PM
RE: Codeigniter - Indonesia Community - by cakka - 11-07-2015, 07:10 AM
RE: Codeigniter - Indonesia Community - by redha - 01-27-2016, 09:12 PM
RE: Codeigniter - Indonesia Community - by epox2 - 02-17-2016, 08:25 PM
RE: Codeigniter - Indonesia Community - by akuila - 03-21-2016, 02:23 AM
RE: Codeigniter - Indonesia Community - by needle - 04-14-2016, 03:41 PM
website dengan codeigniter - by suhindra - 04-16-2016, 07:36 AM
RE: Codeigniter - Indonesia Community - by aldy - 04-19-2016, 03:05 AM
RE: Codeigniter - Indonesia Community - by siprox - 05-22-2016, 11:34 PM
RE: Codeigniter - Indonesia Community - by unto - 06-07-2016, 01:46 PM
RE: Codeigniter - Indonesia Community - by adty - 06-26-2016, 09:14 PM
RE: Codeigniter - Indonesia Community - by citra - 09-02-2016, 09:20 PM
RE: Codeigniter - Indonesia Community - by Wau - 10-06-2016, 10:35 PM
RE: Codeigniter - Indonesia Community - by twonno - 12-07-2016, 08:04 PM
RE: Codeigniter - Indonesia Community - by uyak - 01-05-2017, 08:54 PM
RE: Codeigniter - Indonesia Community - by rofik - 02-23-2017, 08:47 PM
RE: Codeigniter - Indonesia Community - by dycas - 01-22-2017, 05:15 PM
RE: Codeigniter - Indonesia Community - by mrw7a - 05-01-2017, 08:43 PM
RE: Codeigniter - Indonesia Community - by tamam - 10-10-2017, 07:01 PM
RE: Codeigniter - Indonesia Community - by Wily23 - 11-03-2017, 01:42 AM
RE: Codeigniter - Indonesia Community - by Wily23 - 11-03-2017, 05:47 AM
RE: Codeigniter - Indonesia Community - by DELE - 09-10-2018, 08:06 AM
RE: Codeigniter - Indonesia Community - by gopei - 10-23-2018, 07:19 PM
RE: Codeigniter - Indonesia Community - by 49boys - 04-29-2019, 05:56 PM
RE: Codeigniter - Indonesia Community - by imam - 11-30-2019, 10:04 AM
RE: Codeigniter - Indonesia Community - by Haidir - 12-03-2019, 10:54 AM
RE: Codeigniter - Indonesia Community - by siprox - 03-31-2020, 01:53 AM
RE: Codeigniter - Indonesia Community - by nuja - 11-13-2020, 02:00 AM
RE: Codeigniter - Indonesia Community - by bangil - 07-27-2020, 12:40 AM
RE: Codeigniter - Indonesia Community - by nuja - 11-13-2020, 02:03 AM
RE: Codeigniter - Indonesia Community - by aahas - 08-20-2021, 12:02 AM
RE: Codeigniter - Indonesia Community - by cocix - 11-08-2021, 07:06 PM
RE: Codeigniter - Indonesia Community - by dewaz - 11-09-2021, 03:27 AM
RE: Codeigniter - Indonesia Community - by myads - 08-26-2022, 12:55 AM
RE: Codeigniter - Indonesia Community - by erysai - 06-26-2024, 10:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB