
Controller
application\controllers\welcome.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <?php class Welcome extends CI_Controller { public function index() { //Form Validation $this ->load->helper( array ( 'form' , 'url' )); $this ->load->library( 'form_validation' ); $this ->form_validation->set_rules( 'username' , 'Username' , 'required' ); $this ->form_validation->set_rules( 'password' , 'Password' , 'required' ); $this ->form_validation->set_rules( 'passconf' , 'Password Confirmation' , 'required' ); $this ->form_validation->set_rules( 'email' , 'Email' , 'required' ); //Validation Functions //$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[users.username]'); //$this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]'); //$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required'); //$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]'); if ( $this ->form_validation->run() == FALSE) { $this ->load->view( 'welcome_message' ); } else { $this ->load->view( 'formsuccess' ); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <?php echo validation_errors(); ?> <?php echo form_open( 'welcome' ); ?> <h5>Username</h5> <input type= "text" name= "username" value= "<?php echo set_value('username'); ?>" size= "50" /> <h5>Password</h5> <input type= "text" name= "password" value= "<?php echo set_value('password'); ?>" size= "50" /> <h5>Password Confirm</h5> <input type= "text" name= "passconf" value= "<?php echo set_value('passconf'); ?>" size= "50" /> <h5>Email Address</h5> <input type= "text" name= "email" value= "<?php echo set_value('email'); ?>" size= "50" /> <div><input type= "submit" value= "Submit" /></div> </form> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <h5>Username</h5> <?php echo form_error( 'username' ); ?> <input type= "text" name= "username" value= "<?php echo set_value('username'); ?>" size= "50" /> <h5>Password</h5> <?php echo form_error( 'password' ); ?> <input type= "text" name= "password" value= "<?php echo set_value('password'); ?>" size= "50" /> <h5>Password Confirm</h5> <?php echo form_error( 'passconf' ); ?> <input type= "text" name= "passconf" value= "<?php echo set_value('passconf'); ?>" size= "50" /> <h5>Email Address</h5> <?php echo form_error( 'email' ); ?> <input type= "text" name= "email" value= "<?php echo set_value('email'); ?>" size= "50" /> |