Welcome Guest, Not a member yet? Register   Sign In
cannot send hidden fields to the controller
#5

[eluser]boltsabre[/eluser]
On a side note, why you passing stuff like

Code:
$today =date("Y-m-d");
$hidden = array('data_criacao' => $today, 'identidade' => $this->session->userdata('user_id'));

from your view, to your controller, and then finally to your model?

- You exposed the "user_id" in a public html form (it MAY be a security problem),
- You've created extra coding for yourself (thus potential for extra bugs).
- You've made extra variables (thus making your server work harder)
- You're html code is now bigger (increasing the size of the file that needs to be served to the user, eating up your bandwidth, etc).

You could have easily just done this in your model!
Code:
$new_data=array(
     'identidade'=>$this->session->userdata('user_id'),
     'titulo'=>$data['titulo'],
     'descricao'=>$data['descricao'],
     'referencia'=>$data['referencia'],
     'data_criacao'=>date("Y-m-d"),
     'nome_empresa'=>$data['nome_empresa'],
     'email'=>$data['email'],
     'local_de_trabalho'=>$data['local_de_trabalho']);

Don't feel bad, I think we all start coding like this, but this is a much better way of coding, you should only ever assign something to a variable if you absolutely have to! Glad you go your problem solved!


Messages In This Thread
cannot send hidden fields to the controller - by El Forum - 10-18-2012, 11:16 AM
cannot send hidden fields to the controller - by El Forum - 10-18-2012, 11:49 AM
cannot send hidden fields to the controller - by El Forum - 10-18-2012, 12:02 PM
cannot send hidden fields to the controller - by El Forum - 10-18-2012, 12:38 PM
cannot send hidden fields to the controller - by El Forum - 10-19-2012, 05:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB