[eluser]Daksh Mehta[/eluser]
Hello,
thanks for your help but its still not working, i can't understand why its not working.
here is my new process() function:
Code:
public function process(){
$this->load->helper('security');
$username = $this->input->post("username");
$passwd = do_hash($this->input->post("password"));
$email = $this->input->post("email");
$this->load->model('members');
$this->members->register($username, $passwd, $email);
$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);
}
and here is my members.php model used in the above function:
Code:
<?php
class Members extends CI_Model {
public function register($username, $password, $email){
$sqlq = "INSERT INTO members VALUES(?, ?, ?, ?)";
$this->db->query($sqlq, array(NULL, $username, $password, $email));
}
}
?>
Its still inserting 2 rows..
I am not understanding why its not working. Actually, i have created one library for retrieving and saving setting of portals into the database, which is as follow:
Code:
<?php
class Setting {
private $CI, $value;
public function __construct(){
$this->CI = & get_instance();
$this->CI->load->database();
}
public function add($option, $value){
$data = $this->get(array($option));
if(isset($data[$option])){
$this->update($option, $value);
}
else {
$sql = "INSERT INTO config VALUES(?, ?)";
$this->CI->db->query($sql, array($option, $value));
}
}
public function update($option, $value){
$sql = "UPDATE config SET value=? WHERE ukey=?";
$this->CI->db->query($sql, array($value, $option));
}
public function _get($option = ""){
$sql = "SELECT * FROM config WHERE ukey = ?";
$result = $this->CI->db->query($sql, array($option));
$this->value = $result->row_array();
return $this->value['value'];
}
public function get($options = array(), $parse = FALSE){
$data = array();
$i = 0;
foreach($options as $option){
if($parse == FALSE)
$data[$option] = $this->_get($option);
else
$data[$i++][$option] = $this->_get($option);
}
return $data;
}
}
?>
When we are accessing the add() function, its working fine and inserting only one row.
Please, if possible experiment it practically and let me know what you say about it.
Again thanks to all, looking forward for help!