Skip to main content

buat fungsi redirect

4 replies [Last post]
does not have a status.
ecaiseng's picture
User offline. Last seen 10 weeks 1 day ago. Offline
Joined: 02/28/2011

salam CI,,

CI master & bang admin Q mw nanya ni..
Q punya tabel dengan field 'log_it'...

Nah bagaimana caranya agar kalau 'log_it' = 1 maka fungsi akan di redirect ke 'halaman A' sedangkan kalau 'log_it' = 0 akan di redirect ke 'halaman B'...

mohon pencerahannya CI master & bang admin,,
trims

->ace<-

does not have a status.
ecaiseng's picture
User offline. Last seen 10 weeks 1 day ago. Offline
Joined: 02/28/2011
Udah Bisa

Thx atas inspirasinya...
Q pake cara ini..jd halaman g pake fungsi direct...
Klu log_it = 0 link terlihat
klu log_it = 1 link tak terlihat

/libraries/.php
/*....*/

public function get_log_it()
{		$query=$this->CI->db->get_where('mahasiswa_it', array('username'=>$this->CI->session->userdata('logged_user')));
		if ( $query->num_rows() == 1 )
		{
			$row = $query->row();
			return $row->log_it;
		}
		return FALSE;
}

/views/.php
/**....*/

if($log_it == 0)
{
	echo '<ul><li>';
	echo anchor('admin/it' , 'Survey IT Kompetensi');
	echo '</ul></li>';
}

->ace<-

Talk is cheap. Show me the code.
Kazel's picture
User offline. Last seen 9 weeks 3 days ago. Offline
Joined: 01/28/2011
Coba gini deh...

Model:

function cek_log($current_user)
{
	$cek=$this->db->get_where('mahasiswa_it',array('id'=>$current_user));
	if($cek->row()->log_it==1) return TRUE;
	else return FALSE;
}

Controller:

if($this->[nama_model]->cek_log($current_user)) redirect('admin/trims');
else redirect('admin/??');

does not have a status.
predhtz's picture
User offline. Last seen 7 hours 25 min ago. Offline
Joined: 01/07/2010
logika yang paling sederhana

logika yang paling sederhana adalah...

$redirect_url = ($log_it == 1) ? "halaman_a":"halaman_b";
redirect($redirect_url);

does not have a status.
ecaiseng's picture
User offline. Last seen 10 weeks 1 day ago. Offline
Joined: 02/28/2011
kok g bisa y...

Saya coba pake cara ini

$this->db->get('log_it');
$this->db->from('mahasiswa_it');
$this->db->where('id',$current_user);

$redirect_url = ($log_it == 1) ? "admin/trims":"admin/??";
redirect($redirect_url);

kok tetap g bisa y??
apa ad yang salah dengan logika ini??

->ace<-

Premium Drupal Themes by Adaptivethemes