--
-- Database: `registration`
--
CREATE TABLE IF NOT EXISTS `user_registration` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `phone` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

--
-- Dumping data for table `user_registration`
--

INSERT INTO `user_registration` (`id`, `name`, `email`, `password`, `phone`) VALUES
(1, 'madhurendra', 'madhurendra.rit@gmail.com', '123456789', '8802367534\r\n');






 autoload.php :   
 We have to change in autoload.php as follows,  

 $autoload['libraries'] = array('database', 'session');
 $autoload['helper'] = array('url');




View (registration.php) Registration page is like: -

	
	Welcome to CodeIgniter

	


Name
Email
Password
Phone
View (registration.php) Registration page is like: -
load->helper('form');
		$this->load->view('registration');
		
	}
public function page(){
	    $this->load->library('session');
		if($this->session->userdata('login')!=''){
		$this->load->view('home');	
		}else{
		redirect('home/login');
		}
	}
public function registration(){
	$this->load->helper('form');
	$this->load->library('form_validation');
	$this->form_validation->set_error_delimiters('
', '
'); $this->form_validation->set_rules('name', 'Name', 'required'); $this->form_validation->set_rules('email', 'Email','required|valid_email|is_unique[user_registration.email]'); $this->form_validation->set_rules('password', 'Password', 'required'); $this->form_validation->set_rules('phone', 'Phone Number', 'required'); if ($this->form_validation->run() === FALSE) { $this->load->view('registration'); } else { $data=array('name'=>$this->input->post('name'),'email'=>$this->input->post('email'),'password'=>$this->input->post('password'), 'phone'=>$this->input->post('phone')); $query=$this->db->insert('user_registration',$data); $this->load->library('session'); $this->session->set_flashdata('success','Registration Successfully Please Login Here'); redirect('home/login','refresh'); } } public function login(){ $this->load->helper('form'); $this->load->library('session'); $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('
', '
'); $this->form_validation->set_rules('email', 'Email','required|valid_email'); $this->form_validation->set_rules('password', 'Password ', 'required'); if ($this->form_validation->run() === FALSE) { $this->load->view('login'); } else{ $email=$this->input->post('email'); $password=$this->input->post('password'); $data['checkdata']=$this->common->check_password($email,$password); if(!empty($data['checkdata'])){ $logindata = array( 'name' =>$data['checkdata'][0]['name'] , 'id' =>$data['checkdata'][0]['id'] , 'email' =>$data['checkdata'][0]['email'] ); $this->load->library('session'); $this->session->set_userdata('login',$logindata); redirect('home/page','refresh'); }else{ $data['loginerror']="UserDetails Wrong Please Try Again"; $this->load->view('login',$data); } } } function logout(){ $this->session->unset_userdata('login'); redirect('home','refresh'); } function getData($id=Null){ echo $id; } } ?>
Model (common.php)
db->get_where('user_registration', array('email' => $email,'password'=>$password));
		return $query->result_array();
		}
}
?>

0 comments :

Post a Comment

 
# Top