codeigniter表单不提交给控制器中的方法

时间:2014-05-27 05:02:16

标签: php forms codeigniter submit

我在测试服务器上看到一个奇怪的行为。在我的localhost中,应用程序正常工作。一旦我上传codeigniter来测试服务器更新 config.php / database.php 并尝试登录,就不会调用特定方法。

$_POST数组有值。正在成功调用index方法。我已经在autoload中加载了所有帮助文件。

<form class="form-signin" action="http://hostname/index.php/welcome/logincheck"  method="post">
<input type="text" name="username" class="form-control" placeholder="Username">
<input type="password" name="password" class="form-control" placeholder="Password">
<label for="name">I am a </label>
<select class="form-control" name="role">
   <option value="student">Student</option>
   <option value="teacher">Teacher</option>       
</select><br />
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>

有什么想法吗?

登录检查方法

public function logincheck()
{
    echo "login check function called";

    $this->load->library('session');
        $username=$this->input->post('username');
    $password=$this->input->post('password');
    $role = $this->input->post('role');
    $validity = $this->homefunctions->validate($username,$password,$role);
        if($validity[1])
    { 
     $data=array(
            'username'=>$username,
            'lname'=>$validity[0]['fname'],
            'fname'=>$validity[0]['lname'],
            'role'=>$validity[0]['role'],
            'id'=>$validity[0]['id'],
            'is_logged_in'=> true
        );
    $this->session->set_userdata($data);
                if($role=="teacher")
                   header('Location:/sch/teacher/index');
                else
                   header('Location:/sch/student/index');

                }

    else{
        $data['message']='Username/Password/Role is wrong';
        $data['main_content']='home1';
            $this->load->view('templates/hometemplate',$data); 
        }

  }

0 个答案:

没有答案