【问题标题】:404 Page Not Found (The page you requested was not found.)404 Page Not Found(未找到您请求的页面。)
【发布时间】:2014-02-16 16:54:45
【问题描述】:

我尝试显示 (*localhost/ujian/index.php/user_controller*) 但没有找到,为什么?

代码

class User_controller extends CI_Controller{

function __construct()
{
    parent ::__construct();
      $this->load->model('user_model');
      $this->load->helper(array('form'));
}

function user()
{
    $data['judul'] = 'Daftar User';
    $this->load->view('user', $data);
}

function simpan_user()
{   

    $this->user_model->simpan_user();
    $data['notifikasi'] = 'Data berhasil disimpan';
    $data['judul']='Insert Data Berhasil';
    $this->load->view('notifikasi', $data);
    redirect('user_controller');
}
 function view()
{
    $data['daftar_user'] = $this->user_model->get_user_all();
    $this->load->view('daftar_user', $data);
}
 function delete_user($id)
{
    $data['daftar_user'] = $this->user_model->get_user_all();
    $this->load->view('daftar_user', $data);
    $username = $this->user_model->delete_user($id);
    redirect('user_controller');
}

我尝试显示 (*localhost/ujian/index.php/user_controller*) 但没有找到,为什么?

【问题讨论】:

标签: php mysql codeigniter localhost


【解决方案1】:

当你没有在控制器名称之后指定任何函数名称时,它默认调用 index() 函数。

在您请求的 URL 中没有指定函数名称,因此,它默认调用 index() 函数。但是您请求的控制器中没有定义 Index() 函数。

请,创建一个 index() 函数并尝试。

干杯..!!

【讨论】:

    【解决方案2】:

    根据您的问题,您正在调用 URL:

    localhost/ujian/index.php/user_controller
    

    但是您的控制器没有默认函数 index()。所以添加默认功能并为此网址执行默认操作。

    function index()
    {
        // add your action
        // or call any default function like $this->user();
    }
    

    【讨论】:

    猜你喜欢
    • 2018-04-18
    • 2018-04-18
    • 2016-01-12
    • 2013-07-06
    • 2012-12-30
    • 2017-10-13
    • 2013-01-13
    • 2017-06-19
    • 2020-12-05
    相关资源
    最近更新 更多