Welcome Guest, Not a member yet? Register   Sign In
escaping quotes when updating db
#2

[eluser]murichej[/eluser]
ajax code from view:
Code:
$('#save_personal').click(function() {
    $.ajax({
        type: "POST",
        url: "index.php/profile/savePersonalInformation",
        data: { name: $('#name').val(), surname: $('#surname').val(), about: $('#about').val() },
        success: function(ret) {
            if (ret)
                location.reload();
        },
    });
});

controller code:
Code:
public function savePersonalInformation()
{
    $id = $this->id_admin;
    
    $data['name'] = trim($_REQUEST['name']);
    $data['surname'] = trim($_REQUEST['surname']);
    $data['about'] = trim($_REQUEST['about']);
    
    $OK = $this->Admin_model->setPersonalInformation($id, $data);
    
    if ($OK) {
        echo 1;
        exit;
    }
    
}

model code:
Code:
function setPersonalInformation($id, $data)
{
          
    $this->db->where('id', $id);
    $this->db->update('admin', $data);
    
    if ($this->db->affected_rows() == '1')
        return TRUE;
    
    return FALSE;
}


Messages In This Thread
escaping quotes when updating db - by El Forum - 09-14-2012, 12:18 PM
escaping quotes when updating db - by El Forum - 09-14-2012, 12:30 PM
escaping quotes when updating db - by El Forum - 09-14-2012, 12:43 PM
escaping quotes when updating db - by El Forum - 09-14-2012, 12:52 PM
escaping quotes when updating db - by El Forum - 09-14-2012, 01:02 PM
escaping quotes when updating db - by El Forum - 09-14-2012, 01:51 PM
escaping quotes when updating db - by El Forum - 09-16-2012, 07:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB