[eluser]nikefido[/eluser]
I've been staring at my code trying to figure this out.
So the system is storing credit cards that is encrypted via the CI encryption library.
When the user registers, the credit card number is encoded. When the user goes to their edit-information section, their credit card shows up decoded.
However, if the user edits this number, the problem begins. The new credit card number is re-encoded and then placed back into the DB. I can see that there is a new encrypted string in the database for that user.
However, when the page decodes the NEW credit card number...it can't. It displays nothing!
I have looked at the code carefully to make sure that there is no typo or error - it's doing the same process each time.
The only thing I can see different is that the first time, an INSERT query is used, and the second time is an active-record UPDATE.
INSERT:
Code:
$sql = "INSERT INTO mytable (title, name)
VALUES (".$this->db->escape($title).", ".$this->db->escape($name).")";
$this->db->query($sql);
UPDATE:
Code:
$billdata = array(/*info here*/);
$this->db->where('u_id', $id);
$this->db->update('b_info', $billdata);
Both times, the card number being entered is retrieved via:
Code:
$cNum = $this->encrypt->encode($this->input->post('cNum', TRUE));
However, I use $this->db->escape in my INSERT statement, which is also supposedly used in the active-record UPDATE statement (according to the codeigniter manual).
Does anyone have any idea why this may be happening? Is there some step changing the encrypted string?
(my encryption key is set in the config file)