这是我的视图/login/loginform.php
<?php echo form_open('scheduler/login');
?>
<label for="username">username</label>
<input type="text" name="username"/><br/>
<label for="password">password</label>
<input type="password" name="password"></input><br/>
<input type="submit" name="submit" value="log in" />
</form>
这是我的控制器/Scheduler.php
<?php
class Scheduler extends CI_Controller {
public function login()
{
$this->load->helper('form');
echo"not logged in";
$username=$this->input->post("username");
$password=$this->input->post("password");
if($username=="123" && $password="abc"){
$data['username']=$username;
$this->load->view('login/login_success_message',$data);
//$this->input->set_cookie('123','abc','15');
// redirect('home');
}
else {
$this->load->view('login/login_failure_message');
//$this->load->view('login/loginform');
}
}
}
?>
但是,当我去http://localhost/project/scheduler/login
//$this->load->view('login/loginform');
您没有加载登录表单。因此,取消注释上面的行
$this->load->view('login/loginform');
如果问题仍然存在,则尝试调用$this->load->view('login/loginform');
out-side if else语句