簡體   English   中英

HREF鏈接正在復制PHP

[英]HREF link is duplicating PHP

我的網站鏈接有問題。 我正在使用CodeIgniter和PHP。 我試圖通過使用href =“controllers_name / function_name”引用它來訪問頁面。 但這發生了。

這是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>

這是函數調用:

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');
}

當我嘗試單擊其他按鈕時,它不起作用(頁面與CodeIgniter的歡迎頁面分開)。

您必須使用site_url()base_url()來進行codeigniter,以了解要調用的控制器方法。 你只是在做href="home/login" ,而你必須這樣做

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

所以你的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>

希望這可以幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM