[eluser]asmaa kamal[/eluser]
hi
i try to code
login page to website
i got this error
Quote:Not Found
The requested URL /t/main/login was not found on this server.
i got this error if i login by accepted email, password or if i login by unaccepted one
this is main code(in controller)
Code:
<?php
class Main extends CI_Controller {
function Main()
{
parent::__construct();
$this->load->model('user_model');
}
public function login()
{
$this->form_validation->set_rules('userEmail','email','trim|required|valid_email|callback_check_login');
$this->form_validation->set_rules('userPassward','passward','trim|required');
if($this->form_validation->run())
{
if($this->user_model->Login(array('userEmail'=>$this->input->post('userEmail'),'userPassward'=>$this->input->post('userPassword'))));
{redirect('dashboard');}
redirect('main/login');}
$this->load->view('main/login_form');
}
function index()
{
$this->load->view('main/main_index');
}
function _check_login($userEmail)
{
if ($this->input->post('userPassward'))
{
$user=$this->user_model->GetUsers(array('userEmail'=>$userEmail,'userPassward'=>md5($this->input->post('userPassword'))));
if($user) return true;
}
$this->form_validation->set_message('_check_login','your username/passward is invalid.');
return false;
}
}
and this is view code
Code:
<?php echo form_open(base_url() . 'main/login')?>
<fieldset>
<legend>Login Form </legend>
<ul>
<li>
<label>Email</label>
<?php echo form_input('userEmail',set_value('userEmail'))?>
<?php echo form_error('userEmail')?>
</li>
<li>
<label>password</label>
<?php echo form_password('userPassword')?>
<?php echo form_error('userPassword')?>
</li>
<li>
<?php echo form_submit('','login')?>
</li>
</ul>
</fieldset>
<?form_close()?>
and this is model code
Code:
<?php
class User_Model extends Model {
function _required($required,$data)
{
foreach($required as $field)
if(!isset($data[$field])) return false;
return true;
}
function AddUser($options=array())
{
if(!$this->_required(array('userEmail','userPassword'),$options)) return false;
$options=$this->_default(array('userStatus','active'),$options);
$this->db->insert('users',$options);
return $this->db->insert_id();
}
function UpdateUser($options=array())
{
if(!$this->_required(array('userId'),$options)) return false;
if(isset($options['userEmail']))
$this->db->set('userEmail',$options['userEmail']);
if(isset($options['userPassword']))
$this->db->set('userPassword',md5($options['userPassword']));
if(isset($options['userStatus']))
$this->db->set('userStatus',$options['userStatus']);
$this->db->update('users');
return $this->db->affected_rows();
}
function _default($defaults,$options)
{
return array_merge($defaults,$options);
}
function GetUsers($options=array())
{
if(isset($options['userId']))
$this->db->where('userId',$options['userId']);
if(isset($options['userEmail']))
$this->db->where('userEmail',$options['userEmail']);
if(isset($options['userStatus']))
$this->db->where('userStatus',$options['userStatus']);
if(isset($options['userPassword']))
$this->db->where('userPassword',$options['userPassword']);
if(isset($options['limit'])&&isset;($options['offset']))
$this->db->limit($options['limit'],$options['offset']);
else if(isset($options['limit']))
$this->db->limit($options['limit']);
if(isset($options['sortBy'])&&isset;($options['sortDirection']))
$this->db->order_by($options['sortBy'],$options['sortDirection']);
$query=$this->db->get('users');
if(isset($options['userId'])||isset($options['userEmail']))
return $query->row(0);
return $query->result();
}
function Login($options=array())
{
if(!$this->_required(array('userEmail','userPassword'),$options)) return false;
$user=$this->GetUsers(array('userEmail'=>$options['userEmail'],'userPassword'=>md5($options['userPassword'])));
if(!$user) return false;
$this->session->set_userdata('userEmail',$user->userEmail);
$this->session->set_userdata('userId',$user->userId);
return true ;
}
}
?>
i think the problem in redirect method ( in main in controller) but when i stop this part i got the same error and when i try this
Code:
if($this->user_model->Login(array('userEmail'=>$this->input->post('userEmail'),'userPassward'=>$this->input->post('userPassword'))));
{redirect('index.php/dashboard');}
redirect('index.php/main/login');}
plz help me
thanks