Welcome Guest, Not a member yet? Register   Sign In
pass an argument to controller function
#1

[eluser]rotivo[/eluser]
Hello, i want to pass an argurment to controller function but i don“t want to show this argument in the URI... how can i do it? Thanks.
#2

[eluser]boltsabre[/eluser]
The most common ways to pass it is either as a form element (generally an input with type="hidden"), or via a session/flashdata or cookie.

hidden inputs are still open to easy manipulation by users, there are now browser plugins that easily let users play with post data, so this is not a secure way of passing sensitive information!!! Same applies to cookies, very easy for the user to alter the data in them.

What are you trying to do?
#3

[eluser]rotivo[/eluser]
In an a form I pass 1 if the form was sent correctly and 0 if the form sent fails...in the controller depends of the param, loads a view or other...thanksss
#4

[eluser]Samus[/eluser]
[quote author="rotivo" date="1337786188"]In an a form I pass 1 if the form was sent correctly and 0 if the form sent fails...in the controller depends of the param, loads a view or other...thanksss[/quote]
Why don't you utilize the resources CI gives you?

You can do this simply with the form validation class.

e.g
Code:
if ($this->form_validation->run() == FALSE)
  {
   $this->load->view('myform');
  }
  else
  {
   $this->load->view('formsuccess');

http://ellislab.com/codeigniter/user-gui...ation.html
#5

[eluser]rotivo[/eluser]
Because I only load a popup if the form sent is successs, the page is the same..not change! but i can try in your way...
#6

[eluser]Samus[/eluser]
[quote author="rotivo" date="1337786786"]Because I only load a popup if the form sent is successs, the page is the same..not change! but i can try in your way...[/quote]
In that case, you could use it to check if the form validation is successful, if it is, assign a variable and then use that variable to determine whether the popup should load or not.

e.g

Code:
if ($this->form_validation->run() == FALSE)
  {
   $data['success'] = 0; // fail :(
  }
  else
  {
   $data['success'] = 1; // success!
  }
$this->load->view('some_view', $data);

then in your view.

Code:
if($success) {
  // markup for loading popup
}

That's just off the top of my head though, i'm sure you can improve it. Smile
#7

[eluser]rotivo[/eluser]
thanks. wonderfull. Smile




Theme © iAndrew 2016 - Forum software by © MyBB