简体   繁体   中英

The requested URL was not found on this server. on php codeigniter

I am a beginner to codeigniter and, I'm trying to make an inventory system. The dashboard is ready, but when I click a button on dashboard it gives an error, it is not loading the new product view I defined the routes tried much but no positive result

Here is my controller

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Dashboard extends CI_Controller {

    public function _construct(){
        parent::_construct();
        $this->load->database();

        $this->load->model("m_inventory");
        $this->load->helper('form');
        $this->load->library('form_validation');
    }

    public function add_items(){
        $this->load->view('newproduct');
    }
}

And my dashboard view

<div class="form">
    <h2>Inventory System</h2>
    <div class="button1">
        <a title="New account" href='<?php echo base_url ('dashboard/add_items'); ?>New product</a> 
    </div> 
    <div class="button2">
        <input type="submit" name="submit" value="Current Stock" > 
    </div>
</div>
  1. Confirm if url helper is loaded in application/config/autoload.php since you are using base_url()
  2. Your view file name should be newproduct.php
  3. Check by adding/removing index.php after base url.

If above doesn't help you then share the error you are getting and CI version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM