doudieheng5322 2015-02-16 17:30
浏览 21

HREF链接正在复制PHP

I'm having a problem with the link of my websites. I'm using CodeIgniter with PHP. I tried to access a page using a function by referring to it with href="controllers_name/function_name". But this happens.

This is the code of the href:

<li><a href="home/login">Dashboard</a></li>
<li><a href="home/customer">Customers</a></li>
<li><a href="home/order">Orders</a></li>
<li><a href="home/product">Products</a></li>
<li><a href="home/logout" ><b>Logout</b></a></li>

Here's the function call:

function customer()
{
    $this->load->view('customer_view');
}

function order()
{
    $this->load->view('order_view');
}

function product()
{
    $this->load->view('product_view');
}

function sales()
{
    $this->load->view('sale_view');
}

function inventory()
{
    $this->load->view('inventory_view');
}

function notes()
{
    $this->load->view('notes_view');
}

function service_offered()
{
    $this->load->view('service_offered_view');
}

function about_us()
{
    $this->load->view('about_us_view');
}

And when I try to click the other buttons, it doesn't work (the pages are separated just like the welcome page of CodeIgniter).

  • 写回答

1条回答 默认 最新

  • douding6266 2015-02-16 22:08
    关注

    You have to use site_url() or base_url() for codeigniter to know what controller method to invoke. You're just doing href="home/login", instead you have to do

    href="<?= site_url('home/login') ?>"
    

    So your html should look like the following

    <li><a href="<?= site_url('home/login') ?>">Dashboard</a></li>
    <li><a href="<?= site_url('home/customer') ?>">Customers</a></li>
    <li><a href="<?= site_url('home/order') ?>">Orders</a></li>
    <li><a href="<?= site_url('home/product') ?>">Products</a></li>
    <li><a href="<?= site_url('home/logout') ?>"><b>Logout</b></a></li>
    

    Hope this helps!

    评论

报告相同问题?

悬赏问题

  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器