[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.