任何人都可以帮助我,为什么我的if代码($ this-> form_validation-> run()== FALSE)总是返回FALSE,即使所有字段都有效。
我已经加载了form_validation,url等应用程序已经在Web服务器上工作但是当我在localhost中部署应用程序时,我挂起了这个错误(from_validation总是返回false)。
这是我的表格:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$email = array(
'name' => 'email',
'id' => 'email',
'class'=> 'input',
'value' => set_value('email'),
'maxlength'=> 80,
'size' => 27,
);
$password = array(
'name' => 'password',
'id' => 'password',
'class' => 'input',
'value' => set_value('password'),
'size' => 27,
);
?>
<div class="row-fluid">
<div class="span8">
<b>Bienvenu!</b>
<p>Identifier-vous pour Accèder à Votre Compte</p>
<p>et Profiter de Nos Services en Ligne </p>
<?php $connect='users/login'; ?>
</div>
</div>
<div class="error"><strong><?=$this->session->flashdata('flashSuccess')?></strong></div>
<div class="login">
<?php $attributes = array('name' => 'loginf', 'autocomplete' => 'off' ); ?>
<?php echo form_open($connect,$attributes );?>
<div class="row-fluid">
<div class="span3">
<?php echo form_label('Adresse Email', $email['id']); ?>
</div>
<div class="span5">
<?php echo form_input($email); ?>
</div>
</div>
<div class="row-fluid">
<div class="span3">
<?php echo form_label('Mot de passe', $password['id']); ?>
</div>
<div class="span5">
<?php echo form_password($password); ?>
</div>
</div>
<div class="row-fluid">
<div class="span4">
<input class="btn" name="submit" type="submit" id="submit" value="Connexion" />
</div>
</div>
</div>
<?php echo form_close()?>
我的控制器,form_validation总是返回false:
<?php
function login(){
$this->load->model('User_m');
$auto=FALSE;
$email=strtolower($this->input->post('email'));
$found="@bmc.com";
$res=strpos($email,$found) ;
if($res > 0){
$role=$this->User_model->getRole(strtolower($this->input->post('email')));
$tiers=$this->User_model->getTiers(strtolower($this->input->post('email')));
if($role=="VEND" && $tiers==""){
$auto=TRUE;
$this->form_validation->set_rules('email', 'Email Address', 'xss_clean|trim|required|valid_email');
}else{
$this->form_validation->set_rules('email', 'Email Address', 'xss_clean|trim|required|valid_email|callback_conten');
}
}else{
$this->form_validation->set_rules('email', 'Email Address', 'xss_clean|trim|required|valid_email|callback_conten');
}
$this->form_validation->set_rules('password', 'Password', 'xss_clean|trim|required|min_length[6]|max_length[20]|callback_password_check');
$this->_email = $this->input->post('email');
$s_pass=$this->security->xss_clean($this->input->post('password'));
$this->_password = sha1($this->_salt .$s_pass);
if($this->form_validation->run() == FALSE){
$this->tmpl_login['success']=NULL;
$this->tmpl_login['auth']='style="display:block"';
$this->tmpl_login['p_o']='style="display:none"';
$this->layout->view_menu_top('menul');
$this->layout->view('compte/login',$this->tmpl_login);
}else{
$this->auth->login('email');
$dv=$this->find_date_visit();
if($auto==FALSE){$this->_SendDynamiqueMessage($this->_email);}
$this->session->set_userdata('name',$this->find_name_user($this->_email));
$this->session->set_userdata('quality',$this->find_quality_user($this->_email));
$this->session->set_userdata('date_visite',$dv);
$this->session->set_userdata('email',$this->_email);
$user_agent = get_browser(null, true);
$this->db->query("insert into us_connexion values ('". $this->_email."',sysdate,'". $user_agent['platform']."','". $user_agent['parent']."')");
if(!$dv){
$this->session->set_userdata('date_visite','premier visite');
redirect('users/password');
}
redirect('users/index');
}
}
?>
PS:我使用了codeigniter 2.0.2版本。 请帮忙! 认为