简体   繁体   English

HREF链接正在复制PHP

[英]HREF link is duplicating PHP

I'm having a problem with the link of my websites. 我的网站链接有问题。 I'm using CodeIgniter with PHP. 我正在使用CodeIgniter和PHP。 I tried to access a page using a function by referring to it with href="controllers_name/function_name". 我试图通过使用href =“controllers_name / function_name”引用它来访问页面。 But this happens. 但这发生了。

This is the code of the href: 这是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). 当我尝试单击其他按钮时,它不起作用(页面与CodeIgniter的欢迎页面分开)。

You have to use site_url() or base_url() for codeigniter to know what controller method to invoke. 您必须使用site_url()base_url()来进行codeigniter,以了解要调用的控制器方法。 You're just doing href="home/login" , instead you have to do 你只是在做href="home/login" ,而你必须这样做

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

So your html should look like the following 所以你的HTML应该如下所示

<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! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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