Welcome Guest, Not a member yet? Register   Sign In
Active Record "insert" is not working properly
#1

[eluser]Daksh Mehta[/eluser]
Hello friends,

I am new to CI and developing my first application.
I am using active record "insert" to insert a member into database from registration page, but its not working properly.

The problem with active record is that , whenever i am using the insert(), its adding one extra record in it with values 0 for all fields.

Here is my controller:
Code:
<?php
class Register extends CI_Controller {
    public static $step;
    public $data;
    public function __construct(){
        parent::__construct();    
        $this->step = 1;

    }
    public function index(){
                $this->data['name_username'] = "username";
        $this->data['name_password'] = "password";
        $this->data['name_repassword'] = "password2";
        $this->data['name_email'] = "email";
        $this->data['name_submitBtn'] = "regBtn";
        $this->data['title'] = "Register";
        $this->template->render($this->data);
    }
    public function process(){
        $this->load->helper('security');
        $username = $this->input->post("username");
        $passwd = do_hash($this->input->post("password"));
        $email = $this->input->post("email");    
        $sql = array(
        'username' => $username,
        'password' => $passwd,
        'email' => $email
        );
        $this->db->insert('members', $sql)

        $this->data['title'] = "Registration done!";
        $this->data['msg'] = "A private key of your account has been sent to your email address. Please, enter it in below form to confirm your account.";
            $this->template->render($this->data);
    }
}
?>
So,
the table will look like:
ID username password email
1 dax abc [email protected]
2 0 0 0

where, the record with ID 2 is automatically added without execution any kind of query.

My view is located in /views/default/register/process.php
Code:
{header}
<h1>{title}</h1>
<p>
{msg}
</p>
{footer}

Please, let me know why its happening with solution.


Messages In This Thread
Active Record "insert" is not working properly - by El Forum - 07-31-2011, 09:13 AM
Active Record "insert" is not working properly - by El Forum - 08-01-2011, 08:55 PM
Active Record "insert" is not working properly - by El Forum - 08-01-2011, 08:58 PM
Active Record "insert" is not working properly - by El Forum - 08-01-2011, 09:37 PM
Active Record "insert" is not working properly - by El Forum - 08-02-2011, 12:20 PM
Active Record "insert" is not working properly - by El Forum - 08-02-2011, 05:12 PM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 01:07 AM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 01:36 AM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 02:29 AM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 04:04 AM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 05:49 AM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 02:26 PM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 02:41 PM
Active Record "insert" is not working properly - by El Forum - 08-03-2011, 02:46 PM
Active Record "insert" is not working properly - by El Forum - 08-05-2011, 01:14 PM
Active Record "insert" is not working properly - by El Forum - 08-05-2011, 02:16 PM
Active Record "insert" is not working properly - by El Forum - 08-05-2011, 03:00 PM
Active Record "insert" is not working properly - by El Forum - 08-05-2011, 03:26 PM
Active Record "insert" is not working properly - by El Forum - 08-06-2011, 11:15 AM
Active Record "insert" is not working properly - by El Forum - 08-06-2011, 01:38 PM
Active Record "insert" is not working properly - by El Forum - 08-06-2011, 01:45 PM
Active Record "insert" is not working properly - by El Forum - 08-06-2011, 01:58 PM
Active Record "insert" is not working properly - by El Forum - 08-06-2011, 09:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB