View( r.php)
<?php
if(isset($msg)) echo "$msg";
echo validation_errors();
echo form_open('log/register', 'method=post');
echo form_input('Uname','','placeholder="Enter user name"');
echo form_submit('submit', 'register');
echo form_close();
?>
Controller(log.php)
<?php
class Log extends CI_Controller{
public function index(){
echo $this->load->view('r');
}
public function register(){
$this->load->helper(array('form','url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('Uname','Username','trim|required');
if($this->form_validation->run()==FALSE){
$this->load->view('r');
}
else{
$this->load->model('register');
if($q=$this->register->ins())
$data['msg']="Record Created";
$this->load->view('r',$data);
}
}
}
Model(register.php)
<?php
class Register extends CI_Model{
public function ins(){
$insert_data=array('username'=>$this->input->post('Uname'));
$insert=$this->db->insert('tb',$insert_data);
return $insert;
}
}
?>
<?php
if(isset($msg)) echo "$msg";
echo validation_errors();
echo form_open('log/register', 'method=post');
echo form_input('Uname','','placeholder="Enter user name"');
echo form_submit('submit', 'register');
echo form_close();
?>
Controller(log.php)
<?php
class Log extends CI_Controller{
public function index(){
echo $this->load->view('r');
}
public function register(){
$this->load->helper(array('form','url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('Uname','Username','trim|required');
if($this->form_validation->run()==FALSE){
$this->load->view('r');
}
else{
$this->load->model('register');
if($q=$this->register->ins())
$data['msg']="Record Created";
$this->load->view('r',$data);
}
}
}
Model(register.php)
<?php
class Register extends CI_Model{
public function ins(){
$insert_data=array('username'=>$this->input->post('Uname'));
$insert=$this->db->insert('tb',$insert_data);
return $insert;
}
}
?>
0 comments:
Post a Comment