Welcome Guest, Not a member yet? Register   Sign In
Validation Errors
#1

[eluser]Unknown[/eluser]
hi sorry for this noob question.. im just new in codeigniter and in php.. i was watching the tutorials on login with codeigniter and it was running very well..

problem: validation_errors

on the tutorials.. it say that to display the error when sign up.. i just follow the instruction but error is not displaying on the bottom of my form..

heres my signup view code:

Code:
<div id="signup_form">
&lt;?php
  echo heading("Create an Account", 1);
  
?&gt;
    
    <fieldset>
     <legend>Personal Information</legend>
        
        &lt;?php
  
  $this->load->helper("form");
  
  echo form_open('login/create_member');
  echo form_input('firstname', set_value('First Name', 'First Name'));
  echo form_input('lastname', set_value('Last Name', 'Last Name'));
  echo form_input('email', set_value('Email Address', 'Email Address'));
  
  ?&gt;
        </fieldset>
        
        <fieldset>
         <legend>Login Info</legend>
            
            &lt;?php
  
   echo form_input('username', set_value('User Name', 'User Name'));
   echo form_input('password', set_value('password', 'Password'));
   echo form_input('password2', set_value('password2', 'Confirm Password'));
  
   echo form_submit("submit", "Create Account");
  
  
   ?&gt;
            
            &lt;?php echo validation_errors('<p class="error">'); ?&gt;
            
        </fieldset>
</div>

the controller code :

Code:
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller {


public function signup(){
  $data['main_content'] = "signup";
  
  $this->load->view('include/template', $data);
}

public function create_member(){
  $this->load->library('form_validation');
  // field name, error message, validation rules
  
  $this->form_validation->set_rules('firstname', 'Name', 'trim|required');
  $this->form_validation->set_rules('lastname', 'Last Name', 'trim|required');
  $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
  
  $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[4]');
  $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]|max_length[32]');
  $this->form_validation->set_rules('password2', 'Password Confirmation',  'trim|required|min_length[4]|max_length[32]|matches[password]');
  
  if($this->form_validation->run() == FALSE){
   $this->load->view('signup_form');
  }
  else
  {
   $this->load->model('membership_model');
   if($query = $this->membership_model->create_member()){
    $data['main_content'] = 'signup_successfull';
    $this->load->view('include/template', $data);
   }
   else {
    $this->load->view('signup');
   }
  }

}


}

Model code :
Code:
&lt;?php

class Membership_model extends CI_Model{

function validate(){
  $this->db->where('username', $this->input->post('username'));
  $this->db->where('password', md5($this->input->post('password')));
  $query = $this->db->get('tbl_account');
  
  if($query == 1){
   return true;
  }
}

function create_member(){
  $new_member_insert_data = array(
   'firstname' => $this->input->post('firstname'),
   'lastname' => $this->input->post('lastname'),
   'email' => $this->input->post('email'),
   'username' => $this->input->post('username'),
   'password' => md5($this->input->post('password'))  
  );
  
  $insert = $this->db->insert('tbl_account', $new_member_insert_data);
  return $insert;
}

}

the error display on my web browser is this

Quote:An Error Was Encountered

Unable to load the requested file: signup_form.php

on my opinion.. maybe i got some wrong code or i need to include some config ?? or any thing ?? please help me..

anyways when there is no error on signup form.. it will inserting on database..

thanks.


Messages In This Thread
Validation Errors - by El Forum - 10-29-2012, 04:04 PM
Validation Errors - by El Forum - 10-29-2012, 04:27 PM
Validation Errors - by El Forum - 10-29-2012, 06:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB