Welcome Guest, Not a member yet? Register   Sign In
DB insert help
#1

[eluser]Unknown[/eluser]
hi guys, im just wondering why this i cant make this work.
i have this codes:

viewjust ignore the checkbox hehe
Code:
<?php echo form_open('user/signup')?>
    <p>Please fill in the information below.</p>
    <table>
     <tr>
      <td><label>Username</label></td>
      <td>&lt;?php echo form_input(array('id'=>'username','name'=>'username', 'value'=> set_value('username')));?&gt;</td>
      <td>&lt;?php echo form_error('username'); ?&gt;</td>
     </tr>
     <tr>
      <td><label>Password</label></td>
      <td>&lt;?php echo form_password(array('id'=>'userpassword1','name'=>'userpassword1', 'value'=>''));?&gt;</td>
      <td>&lt;?php echo form_error('userpassword1'); ?&gt;</td>
     </tr>
     <tr>
      <td><label>Confirm Password</label></td>
      <td>&lt;?php echo form_password(array('id'=>'userpassword2', 'name'=>'userpassword2', 'value'=>''))?&gt;</td>
      <td>&lt;?php echo form_error('userpassword2'); ?&gt;</td>
     </tr>
     <tr>
      <td><label>First Name</label></td>
      <td>&lt;?php echo form_input(array( 'id'=>'firstname', 'name'=>'firstname', 'value'=>set_value('firstname') ));?&gt;</td>
      <td>&lt;?php echo form_error('firstname'); ?&gt;</td>
     </tr>
     <tr>
      <td><label>Middle Name</label></td>
      <td>&lt;?php echo form_input(array('id'=>'middlename', 'name'=>'middlename', 'value'=>set_value('middlename')));?&gt;</td>
      <td>&lt;?php echo form_error('middlename'); ?&gt;</td>
     </tr>
     <tr>
      <td><label>Last Name</label></td>
      <td>&lt;?php echo form_input(array('id'=>'lastname', 'name'=>'lastname', 'value'=>set_value('lastname')));?&gt;</td>
      <td>&lt;?php echo form_error('lastname'); ?&gt;</td>
     </tr>
    
     <tr>
      <td><label>Email Address</label></td>
      <td>&lt;?php echo form_input(array('id'=>'emailadd', 'name'=>'emailadd', 'value'=>set_value('emailadd')));?&gt;</td>
      <td>&lt;?php echo form_error('emailadd'); ?&gt;</td>
     </tr>
     <tr>
      <td></td>
      <td>&lt;?php echo form_checkbox('newsletter', 'accept',FALSE).'Yes, I have accept Terms and Agreement';?&gt;</td>
      <td></td>
     </tr>

     <tr>
      <td></td>
      <td>&lt;?php echo form_submit(array('name'=>'register'), 'Register');?&gt;</td>
     </tr>
    </table>
    &lt;?php echo form_close();?&gt;

then i have this in the controller...

Code:
//some validation thing....

else{
   //everything is good
   $username = $this->input->post('username');
   $password = $this->input->post('password');
   $email = $this->input->post('emailadd');
   $firstname = $this->input->post('firstname');
   $middlename = $this->input->post('middlename');
   $lastname = $this->input->post('lastname');

  
   $this->user_model->register_user($username,$password,$email,$firstname,$middlename,$lastname);
  
   echo "done";
  }

and lastly in the model part..

Code:
function register_user($username,$password,$email,$firstname,$middlename,$lastname){

  $sha1_password = sha1($password);
  
  $query_string = "INSERT INTO useraccounts (username,password,email,firstname,middlename,lastname) VALUES (?,?,?,?)";
  
  $this->db->query($query_string, array($username, $sha1_password, $email, $firstname, $middlename, $lastname) );

}
i am having this error..i just dont know what to do

Quote:Error Number: 1136

Column count doesn't match value count at row 1

INSERT INTO useraccounts (username,password,email,firstname,middlename,lastname) VALUES ('markdean','da39a3ee5e6b4b0d3255bfef95601890afd80709','[email protected]','mark dean')

Filename: C:\wamp\www\MakiBIS\system\database\DB_driver.php

Line Number: 330
i have this in my database
Quote:Account_id int(11)
username varchar(255)
password varchar(255)
email varchar(255)
firstname varchar(255)
middlename varchar(255)
lastname varchar(255)



basically i am just making a registration part as a somehow tutorial in the later part of adding data to the main objective of the system but i am now stuck here..pls help. im just starting to learn the basics of codeigniter...thank youn in advance...cheers. Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB