我在 login.php 控制器中创建了一个简单的 process_login 函数。代码:
<?php
Class Login extends Controller {
var $title = 'Login';
function __construct() {
parent::__construct();
$this->load->model('Login_Model');
}
function index() {
$profile['_profile'] = $this->xProfile_Model->GetProfile();
$this->load->view('login', array('title' => $this->title, '_profile' => $profile['_profile']));
}
function process_form() {
$ret['command'] = "login process";
if($this->input->post('username') == 'admin' && md5($this->input->post('pwd')) == 'e6d8b61d43b5a1c5e4727e92351681f6') {
//EMERGENCY ONLY
$data['id'] = '1';
$data['name'] = 'admin';
$data['group_id'] = '1';
$this->session->set_userdata($data);
$ret['msg'] = $this->lang->line('msg_success') . ', ' . $this->lang->line('msg_please_wait');
$ret['status'] = "success";
}
和登录视图:
<form method="post" id="signin" action="<?php echo site_url('login/process_form')?>">
<label for="username">Username</label>
<input id="username" name="username" value="" class="required" tabindex="4" type="text" onkeypress="focusNext('pwd', 'login', this, event)" />
</p>
<p>
<label for="password">Password</label>
<input id="pwd" name="pwd" value="" class="required" tabindex="5" type="password">
</p>
<p class="clear"></p>
<a href="#" class="forgot" style="display:none;" id="resend_password_link">Lupa password?</a>
<p class="remember">
<input id="signin_submit" value="Login" tabindex="6" type="submit"/>
<input id="cancel_submit" value="Batal" tabindex="7" type="button"/>
<input id="batal" value="TES" tabindex="7" type="button" onclick="<?php site_url('login/tes')?>"/>
</p>
</form>
当我按下登录按钮时,那里什么也没有发生。这段代码有什么问题?
我试图采取行动:
site_url('login/process_form'),site_url('login.php/process_form'),base_url;('process_form')
但它仍然无法正常工作!
请帮帮我,谢谢。