Welcome Guest, Not a member yet? Register   Sign In
$this->input->post('do') failed
#1

[eluser]Apfel1988[/eluser]
Hello,

i've been programming with codeigniter in my freetime.
I Like it very much.
Now i put my first project on a live server and i have my first problems.

When i send a Form to the Server i don`t get any informations from $this->input->post() array.
When i sed the Form at my localhost, then i have no Problems.

I searched in the web, but i dont found anything.

I hope anybody can help me.... Sad
#2

[eluser]OwanH[/eluser]
Hi Apfel1988,

Need to know more. Can you post your form code? Also is your server an Apache server? Dedicated, virtual dedicated, shared? Do you have access to the httpd.conf file if it's Apache? I'd prob. be able to help advise you better if you could answer these questions and post the form code.
#3

[eluser]Apfel1988[/eluser]
[quote author="OwanH" date="1229246775"]Hi Apfel1988,

Need to know more. Can you post your form code? Also is your server an Apache server? Dedicated, virtual dedicated, shared? Do you have access to the httpd.conf file if it's Apache? I'd prob. be able to help advise you better if you could answer these questions and post the form code.[/quote]

Hello,

this is my form code:
Code:
<?= form_open('main/questions'); ?>
<p class="more">&lt;?= $this->session->userdata('fm_title') ?&gt;&nbsp; (&lt;?= $question['q']['f_id'] ?&gt;/&lt;?= $this->session->userdata('fm_sum') ?&gt;)</p>
&lt;?php if($error){ ?&gt;
    <p class="error">Bitte fülle das gesamte Formular aus! </p>        
&lt;?php }

    echo '<p class="question">'. $question['q']['question'] .'</p>';

     if($question['type'] == 'TEXT'){
        echo '<p class="answer">&lt;textarea cols="60" rows="10" name="answer"&gt;&lt;/textarea></p>';
    }elseif ($question['type'] == 'PICTURE') {
        echo '<p class="answer"><img src="'. base_url() . '/system/application/img/questions/' . $question['q']['picname'].'"></img></p>';
        echo '<p class="answer">&lt;textarea cols="60" rows="10" name="answer"&gt;&lt;/textarea></p>';
    } elseif($question['type'] == 'CHECK') {
        echo '<p class="answer">&lt;input type="checkbox" name="answerA" value="1" /&gt;'.$question['q']['answerA'].'</p>';
        echo '<p class="answer">&lt;input type="checkbox" name="answerB" value="1" /&gt;'.$question['q']['answerB'].'</p>';
        if($question['q']['answerC']){ echo '<p class="answer">&lt;input type="checkbox" name="answerC" value="1" /&gt;'.$question['q']['answerC'].'</p>'; }
        if($question['q']['answerD']){ echo '<p class="answer">&lt;input type="checkbox" name="answerD" value="1" /&gt;'.$question['q']['answerD'].'</p>'; }
        if($question['q']['answerE']){ echo '<p class="answer">&lt;input type="checkbox" name="answerE" value="1" /&gt;'.$question['q']['answerE'].'</p>'; }
    }elseif($question['type'] == 'RADIO'){
        echo '<p class="answer">&lt;input type="radio" name="answer" value="1" /&gt;'.$question['q']['answerA'].'</p>';
        echo '<p class="answer">&lt;input type="radio" name="answer" value="2" /&gt;'.$question['q']['answerB'].'</p>';
        if($question['q']['answerC']){ echo '<p class="answer">&lt;input type="radio" name="answer" value="3" /&gt;'.$question['q']['answerC'].'</p>'; }
        if($question['q']['answerD']){ echo '<p class="answer">&lt;input type="radio" name="answer" value="4" /&gt;'.$question['q']['answerD'].'</p>'; }
        if($question['q']['answerE']){ echo '<p class="answer">&lt;input type="radio" name="answer" value="5" /&gt;'.$question['q']['answerE'].'</p>'; }
        
    }
    
    ?&gt;
    
    &lt;input type="hidden" value="&lt;?= $question['q']['f_id']+1 ?&gt;" name="qid" /&gt;
    &lt;input type="hidden" value="&lt;?= $question['type'] ?&gt;" name="type" /&gt;
    &lt;input type="hidden" value="1" name="do" /&gt;
    <p class="answer" style="text-align:right;">&lt;input type="submit" style="margin-right:20px;" name="sub_hinzu" value="n&auml;chste Frage"/&gt;&lt;/p>    
&lt;/form&gt;

It was a shared server. And i haven´t got access to the httpd.conf.

What can i do in the httpd.conf when i hav access to them?

I hope it was enough information, so you can help me. Smile

Thank you for that.
#4

[eluser]OwanH[/eluser]
Hey,

Well if you have access to the httpd.conf file you can ensure that it is configured to allow POST variables (I don't see any reason why it wouldn't be though so that's probably not it).

OK looking at your code it appears fine to me...question... which $_POST variable are you attempting to access with $this->input->post()? The title of this thread has $this->input->post('do') but I see no form variable named 'do'.

Also to check if there is data in the $_POST array you can make a call to the print_r PHP function, like so
Code:
print_r($_POST);
. This will dump the elements of the array. Good for quick and dirty debugging of your arrays.
#5

[eluser]Apfel1988[/eluser]
Hello,
you can see the hiddenfield do, what i will check with the Post array.

Code:
&lt;input type="hidden" value="1" name="do" /&gt;

And i debugged the post array with
Code:
print_r($_POST);
but the return value was null... Sad




[quote author="OwanH" date="1229322734"]Hey,

Well if you have access to the httpd.conf file you can ensure that it is configured to allow POST variables (I don't see any reason why it wouldn't be though so that's probably not it).

OK looking at your code it appears fine to me...question... which $_POST variable are you attempting to access with $this->input->post()? The title of this thread has $this->input->post('do') but I see no form variable named 'do'.

Also to check if there is data in the $_POST array you can make a call to the print_r PHP function, like so
Code:
print_r($_POST);
. This will dump the elements of the array. Good for quick and dirty debugging of your arrays.[/quote]
#6

[eluser]OwanH[/eluser]
Quote:And i debugged the post array with
Quote:print_r($_POST);
but the return value was null… Sad

Hmm, the fact that the print_r function returned a value of null means that the $_POST array is not being created by PHP interpreter when you submit the form. Try:

1. Checking the rendered form, meaning the HTML form code that the browser loads when loading the form, and make sure that the method="post" attribute is set.

2. Creating a very simple page with a single form, couple of fields, upload it to your server, fill it out, submit it to a simple PHP script that just dumps the $_POST array data to see if it's empty or not. Do NOT use the CI framework for this, just straight native PHP. This will identify if this is a server issue. If not then I really don't know what else I could advise.
#7

[eluser]Apfel1988[/eluser]
[quote author="OwanH" date="1229386019"]
Quote:And i debugged the post array with
Quote:print_r($_POST);
but the return value was null… Sad

Hmm, the fact that the print_r function returned a value of null means that the $_POST array is not being created by PHP interpreter when you submit the form. Try:

1. Checking the rendered form, meaning the HTML form code that the browser loads when loading the form, and make sure that the method="post" attribute is set.

2. Creating a very simple page with a single form, couple of fields, upload it to your server, fill it out, submit it to a simple PHP script that just dumps the $_POST array data to see if it's empty or not. Do NOT use the CI framework for this, just straight native PHP. This will identify if this is a server issue. If not then I really don't know what else I could advise.[/quote]


The Rendered Source Code looks like:
Code:
&lt;form action="http://garnele88.ohost.de/index.php/main/questions" method="post"&gt;&lt;p class="more">Wie kommst du bei Frauen an ?&nbsp; (1/6)</p>
<p class="question">Hier und da und so bla und keks?</p><p class="answer">&lt;textarea cols="60" rows="10" name="answer"&gt;&lt;/textarea></p>    
    &lt;input type="hidden" value="2" name="qid" /&gt;
    &lt;input type="hidden" value="TEXT" name="type" /&gt;
    &lt;input type="hidden" value="1" name="do" /&gt;
    <p class="answer" style="text-align:right;">&lt;input type="submit" style="margin-right:20px;" name="sub_hinzu" value="n&auml;chste Frage"/&gt;&lt;/p>    
&lt;/form&gt;

We can see, that the Formhelper Works... Smile

Now i created a simple naked php File and send the Form and print_r($_POST) has shown me all Post variables on the server.

I Think its a problem in CI, or what do you mean about that?

Thank you very much.
#8

[eluser]Apfel1988[/eluser]
now i set the project to another server and it works.^^

But i would like to know what the reason was...

Do you have any ideas?
#9

[eluser]OwanH[/eluser]
Nope i have no idea why that would happen... except that the problem may have orginated from your server host Smile. Anyway, glad to know you got it working on a live server.
#10

[eluser]10ha[/eluser]
i've encounter similar situation, where POST data has nothing after submission.

my issue was the input field is using id, instead of name.

wrong
Code:
&lt;input type="text" id="txtUser" /&gt;

correct
Code:
&lt;input type="text" name="txtUser" /&gt;




Theme © iAndrew 2016 - Forum software by © MyBB