Welcome Guest, Not a member yet? Register   Sign In
$this->input->post question
#1

[eluser]ShannenName[/eluser]
Can anyone see what is wrong with this: Note: these aren't the full files
Input form:
Code:
$attributes = array('name' => 'output');
echo form_open('path/to/', $attributes); ?>
//other form fields below this which I have omitted
form_button(array(
                                'type' => 'submit',
                                'class' => 'small',
                                'content' => 'Submit!'
                            ));
echo form_close();

Get form data file:
Code:
$var = $this->input->post('output');
if ($var == FALSE)
        {
            redirect('signin');
        }
        
        else
        {
            echo 'Hello World!';
        }

Thank you for your time
#2

[eluser]mddd[/eluser]
Your FORM is named 'output'. But you need to have an INPUT element called 'output' for $this->input->post('output') to have a value.
You could add a hidden form field, like <input type="hidden" name="formsent" value="1" /> and then check if $this->input->post('formsent')==1 to detect the form being sent.
#3

[eluser]adamp1[/eluser]
Or since you have a submit button, give it a name and value and detect that.
Code:
print form_button(array('name'=>'submit','value'=>'submit','content'=>'submit'));

In Controller
Code:
if($this->input->post('submit'))
{
    redirct('signin');
}

print "Hello World";

You don't need extra hidden fields or anything then.
#4

[eluser]mddd[/eluser]
That is true, but if you have forms with multiple submit buttons, or if you submit forms through javascript, these submit values do not always come through.
#5

[eluser]ShannenName[/eluser]
The page is like this:
option 1 - submit
option 2 - submit
option 3 - submit
and so on because the options are generated based on user input.

adamp1's method would seem to work but I am wondering if what mddd said applies to this.
#6

[eluser]adamp1[/eluser]
So you have 3 submit buttons. Can't you call them the same thing and give them different values?
#7

[eluser]ShannenName[/eluser]
Yes thank you for that. I'm usually pretty good figuring stuff out on my own but I've never had experience with this sort of thing.

It's just that I tried using only a value and then only a name to see what the effect would be and saw that they both need to be there. Subconsiouscly I then concluded that name and value both could not change. Pretty silly but that's just how my mind works :S
#8

[eluser]mddd[/eluser]
That will work; you can have multiple submit buttons with the same name and different values. But still, if the form is not sent through clicking on a button, you will have problems. For instance, if you send it through Javascript. But more importantly, if a user enters some text in a text field and presses Return, many browsers will then submit the form. And you will have no way to check which button was clicked.. maybe the browser will send only the first one, or all of them in a Post array. You can't know.
#9

[eluser]ShannenName[/eluser]
Thank you for the information but luckily this doesn't apply to me. Maybe it will help someone in the future.




Theme © iAndrew 2016 - Forum software by © MyBB