url问题与codeigniter

时间:2013-02-20 19:37:05

标签: php codeigniter

我在following url有一个示例,它将用户发送到基本表单。

表格的代码如下;

<?php  echo validation_errors(); ?>

<?php echo form_open('form'); ?>

<h5>Username</h5>
<input type="text" name="username" value="" size="50" />

<div><input type="submit" value="Submit" /></div>

</form>

如果我理解正确,一旦用户按下“提交”,它应该返回名为“form”的控制器。但它没有按预期工作。

我希望它提交到index.php/form,而是转到/index.php/index.php/form

随意在上面的网址上测试网站并自行查看问题。

3 个答案:

答案 0 :(得分:1)

我只是查看了您的源代码并注意到了这一点:

<form action="http://helios.hud.ac.uk/u0862025/CodeIgniter/index.php/index.php/form" method="post" accept-charset="utf-8">

显示两个“index.php”。这可能意味着您在基本URL和索引页面配置中设置了“index.php”。您应该从其中一个来源中删除“index.php”,最好是从您的base_url中删除。

答案 1 :(得分:1)

检查配置文件中的base_url()。如果它是正确的,那么你可以写这样的形式:

<?php  echo validation_errors(); ?>

<?php echo form_open('controller_name/function_name'); 
      // controller name write your name of controller 
      // and function name write your function 
?>

<h5>Username</h5>
<input type="text" name="username" value="" size="50" />

<div><input type="submit" value="Submit" /></div>

<?php echo form_close(); // don't forget to close correct ?>

答案 2 :(得分:-1)

我曾遇到过这种情况,问题是我在./application/config/config.php文件中的base_url中包含了index.php请检查并删除(如果有)。您也可以通过从index_page键中删除index.php来解决您的问题,但在base_url中包含index.php并不是一个好习惯。

相关问题