我正在處理一個處理大量表單的項目。我搜索並嘗試搜索結果,但他們都沒有工作。Codeigniter:加載視圖後更改URL
我的代碼視圖代碼 「uprofile.php」 如下:
<form class="form-horizontal" method="post" action='<?php echo base_url() . "home/addnewagency" ?>'>
<div class="form-group">
<label for="company" class="col-sm-3 control-label">New Agency Name:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="newagency" name="newagency" placeholder="Plase Enter New Agency Name">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-primary">Add</button>
</div>
</div>
</form>
我的控制器 「home.php」 碼如下:
public function addnewagency() {
$newagency = $this->input->post('newagency');
$this->dis_model->newagency_model(strtoupper($newagency));
$this->loadprofile();
}
public function loadprofile() {
$data['inscompanyname'] = $this->dis_model->getcompany();
$data['agentname'] = $this->dis_model->getagent();
$data['agencyname'] = $this->dis_model->getagency();
$data['clientname'] = $this->dis_model->getclient();
$data['deptname'] = $this->dis_model->getdept();
$this->load->view('uprofile', $data);
}
當我提交表單,所述控制權傳遞給addnewagency()
將數據插入到數據庫中,URL爲http://localhost/dis/home/addnewagency
。回到調用函數後,它轉到loadprofile()
並加載視圖uprofile
。但是,網址仍然保持不變。但是,我想要它作爲http://localhost/dis/home/login並且還想傳遞數據。有沒有人有任何想法如何實現這一目標?
所有積極建議,歡迎...
在此先感謝...
Whats in the same url? – Gopalakrishnan
你嘗試過重定向(「home/login」)嗎?在函數內部addnewagency() – Gopalakrishnan
看起來你在進行會話時正在做這件事。在將值和重定向登錄重定向(「home/login」);之後,您可以銷燬會話。只是一個想法,如果這樣的作品 – Ankit