I want to be able to use codeigniter db escape because it hashes my passwords OK but in the password row it adds two quotes on either side Example 'demo1234'
My salt row does not show it which is OK just the password. On password how do I use my db escape but not having the quotes show up on password row in db.
public function addUserToDatabase() {
$this->load->helper('date');
$username = $this->input->post('username');
$email = $this->input->post('email');
$password = $this->input->post('password');
$this->db->escape($salt = substr(md5(uniqid(rand(), true)), 0, 9)); // Works OK
// Salt does not work if don't use db escape.
$password = $this->db->escape(sha1($salt . sha1($salt . sha1($password)))); // 'demo1234' shows quotes either side off password
$data = array(
'user_id' => "1",
'user_group_id' => "1",
'username' => $username,
'email' => $email,
'salt' => $salt,
'password' => $password,
'ip' => $this->input->ip_address(),
'status' => "1",
'date_added' => mdate('%Y-%m-%d %H:%i:%s', now())
);
$this->db->insert('user', $data);
}
I worked it out I had to do it like this below, all done.
public function addUserToDatabase() {
$this->load->helper('date');
$username = $this->input->post('username');
$email = $this->input->post('email');
$this->db->escape($password = sha1($salt . sha1($salt . sha1($this->input->post('password')))));
$this->db->escape($salt = substr(md5(uniqid(rand(), true)), 0, 9));
$data = array(
'user_id' => "1",
'user_group_id' => "1",
'username' => $username,
'email' => $email,
'salt' => $salt,
'password' => $password,
'ip' => $this->input->ip_address(),
'status' => "1",
'date_added' => mdate('%Y-%m-%d %H:%i:%s', now())
);
$this->db->insert('user', $data);
}