Ich möchte wissen, wie Online-Benutzerstatus zu ändern, wenn der Benutzer sich anmeldet. Ich habe danach gesucht, aber es gibt keine Antwort auf meine Frage. Ich bin neu beim Lernen dieses Codeigniters. Ich wünschte, ihr könnt mir bitte für mein Problem helfen.Online-Benutzerstatus auf Codeigniter
Controller:
public function signdevice() {
$device = $this->input->post('device');
$pass = $this->input->post('password');
$data = array(
'device' => $device,
'password' => $pass,
'status' => $status
);
$status = 1;
$res = $this->db->get_where('devices', $data);
if ($res->num_rows() > 0) {
$this->session->set_userdata(
array(
'signin' => TRUE,
'device' => $device,
'status' => $status
)
);
$data = array('device' => $device, 'password' => $pass, 'status' => 1);
$this->db->where('device', '$device');
$this->db->update('devices', $data);
redirect(base_url('pelanggan'));
} else {
$this->session->set_flashdata('result_login', 'Wrong Username or Password.');
redirect(base_url());
}
}
Modelle:
function login($user,$pass)
{
$this->db->where('device', $user);
$this->db->where('password', $pass);
$query = $this->db->get('devices');
if($query->num_rows()==1) {
return $query->row_array();
} else {
$this->session->set_flashdata('error', 'Username atau password salah!');
redirect('login');
}
}
function update($id,$stat)
{
$data['status'] = $stat;
$stat = 1;
$this->db->where('kd_device', $id);
$this->db->update('devices', $stat);
return TRUE;
}
Abgesehen von nicht speziell $ status = 0 initialisiert, was Sie haben sollte funktionieren? Was ist das eigentliche Problem, das Sie mit Ihrem Code haben? Was lässt dich denken, dass es nicht funktioniert. – TimBrownlaw