Welcome Guest, Not a member yet? Register   Sign In
What could be causing redirect errors?

Can you identify why the "Piket" page is showing a 404 error even though the required code has been added in the view and controller, and the other pages are redirecting successfully?

if ($userdata['tipe'] == 99) {
} else if ($userdata['tipe'] == 88) {
} else if ($userdata['tipe'] == 55) {
} else if ($userdata['tipe'] == 77) {
} }

**P.S : The "Guru", "Admin", and "Sekretaris" successfully redirected, but when I add "piket" shown the error 404**
And here's the code on controller :

public function index()
  $id = $this->session->userdata('id_user');

  $this->load->view('backend/layouts/wrapper', [
  'content' => 'backend/piket/home',
  'title'  => 'Beranda',
  'profile' => $this->user_m->profile($id),
  'userdata' => $id
], FALSE); }
Can you tell me the error of my code?

(This post was last modified: 04-21-2023, 07:50 AM by SubrataJ.)

You are doing it wrong to redirect to a URI path you have to use
PHP Code:
// Go to specific URI path. "admin/home" is the URI path relative to baseURL.
return redirect()->to('admin/home'); 

in your case
PHP Code:
if ($userdata['tipe'] == 99) {
  return redirect->to('admin');
} else if (
$userdata['tipe'] == 88) {
  return redirect->to('guru');
} else if (
$userdata['tipe'] == 55) {
  return redirect->to('piket');
} else if (
$userdata['tipe'] == 77) {
  return redirect->to('sekretaris');

For a brief instruction, I would suggest you check the official documentation. Redirect
Learning Codeigniter 

Based on the code you provided, it seems that the "Piket" page is not being found even though the required code has been added in the view and controller. One possible reason for this error is that the "Piket" page may not exist or may not be located in the correct directory. Another possibility is that there may be a typo in the file name or directory path. Double-check the file name and directory path for the "Piket" page and make sure they are correct.

Theme © iAndrew 2016 - Forum software by © MyBB