doulin3510 2012-10-29 20:47
浏览 63
已采纳

登录表单验证Codeigniter

My form:

<?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);  
                    ?>

I want to use the clientLogin controller which is in (controllers/pages/hndl/clientLogin.php)

clientLogin controller contains:

<?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);

    }
}

?>

When I visit my homepage (called homepage.php) set as default view to load, and press the SUBMIT button, it gives me the ERROR-404 OBJECT NOT FOUND. It goes to the path:

http://localhost/Applications/XAMPP/htdocs/website/homepage.php/clientLogin

What am I doing wrong here? I'm simply trying to use the clientLogin controller to control the form being submitted from homepage.php view. Thanks

  • 写回答

2条回答 默认 最新

  • douhaodang0403 2012-10-29 23:57
    关注

    I believe it is something with your root directories and base_url.

    Your website should be at:

    C:\xampp\htdocs\website
    

    then your DocumentRoot should be set to:

    C:/xampp/htdocs
    

    and your base_url under your codeigniter's config/config.php should be set to:

    http://localhost/website/
    

    then your form should be set to:

    echo form_open('pages/hndl/clientLogin',$clientLoginFormAttr);
    

    That is what I can think/assume your case is?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?