php - Codeigniter Validation form not working -



php - Codeigniter Validation form not working -

i know problem in other question, can't figure out how handle in case. i've been searching while, , can't find solution:

i want 1 form , connect database, goes wrong , it's impossible receive values on database.

here it's view (location: /application/view/pages/home.php):

<?php echo validation_errors();?> <div id="signup" style='position: absolute; left:900px; top: 380px;'> <?php echo form_open('user/signup');?> <input type='text' required="required" placeholder="full name" name="fullname"/><br/> <input type='text' required="required" placeholder="email" name="email"/><br/> <input type='text' required="required" placeholder="password" name="password"/><br/> <input type='text' required="required" placeholder="confirm password" name="confirmpassword"/><br/> <button type="submit" name="submit_signup">sign up</button> <?php echo form_close(); ?>

here controller (location: /application/controllers/user.php):

class user extends ci_controller { public function __construct() { parent::__construct(); $this->load->model('user_model'); } public index(){ $this->load->view('view'); } public function signup(){ $this->load->helper(array('form', 'url')); $this->load->library('form_validation'); $this->load->model('user_model'); $user_id = default; $data = array(){ 'user_id' => $user_id, 'email' => $this->input->post('email'), 'password' => $this->input->post('password'), 'full_name' => $this->input->post('fullname') } $this->user_model->add_user($data); $this->index(); } }

and model (location: /application/models/user_model.php):

<?php class user_model extends ci_model { public function __construct() { $this->load->database(); } public function add_user($data){ $this->load->database(); $this->db->insert('user',$data); } } ?>

you have syntax error in array:

it should be:

$data = array( 'user_id' => $user_id, 'email' => $this->input->post('email'), 'password' => $this->input->post('password'), 'full_name' => $this->input->post('fullname') )

if still didn't work, $user_id int type, give int.

and not doing validation @ all!?

php forms codeigniter validation

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -