2013-12-19 20 views
-1

我正在嘗試提交我的表單。我的形式被稱爲該函數:表單操作不會在php中更正方法

function controller1() 
    { 
    $code = $this->uri->segment(3); 
    $data['content'] = $code;    
      $this->load->view(FRONTEND_DEFAULT, $data); 
      } 

但是,當我提出我的形式,它可以追溯到控制器1的方法,但我希望它去爲另一種形式。我的形式是:

<form id="form1" action="controller2" method="POST"> 
<input type="text" name="textbox">  
<input type="submit" value="submit" name="submit"> 
</form> 

我想它去controller2,但它去controller1

http://my.website.com/controller1/controller2 

如何防止它回到controller1

編輯:我使用codeigniter作爲我的框架。

+0

*爲什麼... *爲什麼你打電話給你的'控制器'controller1'''''control2'?具有描述性。 – Jakub

+0

[Codeigniter中的表單操作被添加到現有URL中]的可能重複(http://stackoverflow.com/questions/11653025/form-actions-in-codeigniter-gets-added-to-the-existing-url)。另外,請嘗試使用[表單助手](http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html) – Phil

回答

1

你需要指定相對或絕對URL

看到http://www.w3schools.com/tags/att_form_action.asp
即行動= 「example.htm」 或行動= 「http://www.example.com/example.htm」

Your action =「controller2」很可能無法解析並返回到輸出表單的頁面,儘管我會認爲如果它無法正確解析該操作會導致錯誤