Powered By Blogger

Tuesday, February 3, 2015

controller

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller {

/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function __construct(){
parent::__construct();
$this->load->helper( array('form', 'url', 'file','language') );
$this->load->library( array('form_validation','session') );
$this->load->model('login_model');

}

public function index()
{
$data['ErrorMessage'] = '';

if($this->input->server('REQUEST_METHOD')=='POST'){

$this->form_validation->set_rules('name', 'Username', 'required|max_length[5]');
$this->form_validation->set_rules('mail', 'mail', 'required');
$this->form_validation->set_rules('number', 'phone', 'required');

if($this->form_validation->run() === FALSE){
$data['ErrorMessage'] = validation_errors();
}
else{
$set_data = array(
'name' => trim($this->input->post('name')),
'mail' => trim($this->input->post('mail')),
'phone' => trim($this->input->post('number'))
);
$this->login_model->signup($set_data);
$this->session->set_flashdata('sucMessage','inserted value success');
redirect(base_url()."","refresh");
}

}

$this->load->view('login',$data);


}

public function view_list(){

$data['details'] = $this->login_model->view1();

$this->load->view('login',$data);
}


}

No comments:

Post a Comment