我的表单:
<?php
echo validation_errors();
$clientLoginFormAttr = array('id'=>'clientLogin');
echo form_open('clientLogin',$clientLoginFormAttr);
## generate field attributes
$userNameInput=array(
'type' =>'text',
'id' => 'clientLogin',
'name' => 'clientUsername',
'maxlength' => '10',
'size' => '20'
);
$passwordInput=array(
'type'=>'password',
'id'=>'clientLogin',
'name'=>'clientPass',
'maxlength'=>'10',
'size'=>'20'
);
$submitBtn=array(
'type'=>'submit',
'id'=>'submit',
'value'=>'',
'name'=>'sendLogon'
);
## generate actual <input> fields
echo '<label>Username:</label>';
echo form_input($userNameInput);
echo '<label>Password:</label>';
echo form_input($passwordInput);
echo form_submit($submitBtn);
?>
我想使用位于(controllers / pages / hndl / clientLogin.php)的 clientLogin 控制器
clientLogin 控制器包含:
<?php
class Clientlogin extends CI_Controller{
function index(){
$this->load->helper(array('url','form'));
$this->load->library('form_validation');
$loginValidation = array(
array(
'field'=>'clientUsername',
'rules'=>'required|min_length[1]|max_length[10]'
),
array(
'field'=>'clientPass',
'rules'=>'required|min_length[1]|max_length[10]'
)
);
$this->form_validation->set_rules($loginValidation);
}
}
?>
当我访问我的主页(称为homepage.php)设置为加载的默认视图时,按下SUBMIT按钮,它会给我ERROR-404 OBJECT NOT FOUND。它走向了道路:
http://localhost/Applications/XAMPP/htdocs/website/homepage.php/clientLogin
我在这里做错了什么?我只是尝试使用clientLogin控制器来控制从homepage.php视图提交的表单。感谢
答案 0 :(得分:0)
尝试更改
echo form_open('clientLogin',$clientLoginFormAttr);
到
echo form_open('pages/hndl/clientLogin',$clientLoginFormAttr);
答案 1 :(得分:0)
我相信它与您的根目录和base_url有关。
您的网站应位于:
C:\xampp\htdocs\website
然后你的DocumentRoot应该设置为:
C:/xampp/htdocs
并且你的codeigniter的config / config.php下的base_url应设置为:
http://localhost/website/
然后您的表单应设置为:
echo form_open('pages/hndl/clientLogin',$clientLoginFormAttr);
这是我能想到/假设你的情况?