CodeIgniter Forums
No $_POST data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: No $_POST data (/thread-19357.html)

Pages: 1 2 3 4


No $_POST data - El Forum - 06-04-2009

[eluser]BenInBlack[/eluser]
New to codeigniter, actually have to use it for this project.

Ok, I'm working with a situation where there will be dynamic number of input fields in a form so i need to use $_POST to iterate thru them

Code:
//Set post arg to vars
foreach ($_POST as $name=>$values) {
    $this->global_class->checkArgFiltered($name);
    echo "{$name} = {$value}";            
}

my form action is

Code:
<form action="<?php $_SERVER['SERVER_NAME'];?>/index.php/pdf/write" method="POST" enctype="text/plain">

I need $_POST to work or I need a codeignter method.

i tried calling $this->input->post() with out param hoping that it would return an array of the post args

Please help!


No $_POST data - El Forum - 06-04-2009

[eluser]Colin Williams[/eluser]
So just iterate over $_POST like in your first example. What's wrong with that?


No $_POST data - El Forum - 06-04-2009

[eluser]BenInBlack[/eluser]
it's empty, non of the post args are getting thru codeigniter

this is codeigniter blocking this because I have other project running on this server that are not CI


No $_POST data - El Forum - 06-04-2009

[eluser]gtech[/eluser]
to itterate what Colin has said.. here is an example test controller (which I have tested):
Code:
<?php
class Test extends Controller {

  function Test()
  {
    parent::Controller();
  }
  function index()
  {
    // should load a view but for demonstration purposes
    echo ("<FORM action='".site_url()."/test/res' method='post'>
           <INPUT type='TEXT' name='testp'><input type='submit'></FORM>");
  }
  function res()
  {
    print_r($_POST);
  }
}
?>

result after submitting form

Code:
Array ( [testp] => datatypedin )



No $_POST data - El Forum - 06-04-2009

[eluser]BenInBlack[/eluser]
let me re-iterate ;-) $_POST is empty


No $_POST data - El Forum - 06-04-2009

[eluser]gtech[/eluser]
have you tried cut and pasting my example?
it works here.


No $_POST data - El Forum - 06-04-2009

[eluser]slowgary[/eluser]
And if you want the added security of the input class, do this:
Code:
foreach($_POST as $key => $value)
{
     $post_array[$key] = $this->input->post($key);

     //optional 2nd parameter of post() method runs xss filter if set to TRUE
     // e.g. $this->input->post($key, TRUE);
}

P.S. "Having" to use CodeIgniter is not a punishment, it's a privilege ;-)


No $_POST data - El Forum - 06-04-2009

[eluser]Thorpe Obazee[/eluser]
[quote author="BenInBlack" date="1244180370"]let me re-iterate ;-) $_POST is empty[/quote]

Then there must be another problem with your code. You probably need to show more code.


No $_POST data - El Forum - 06-04-2009

[eluser]BenInBlack[/eluser]
first off, thanks for the responses.


Controller

Code:
class Pdf extends Controller {

    function Pdf()
    {
        parent::Controller();    
    }
    
    //the index function is what is called first on instantiation
    function index()
    {
    }
    
    function read() {
        $this->load->library('global_class');
        $this->load->database();
        $this->load->view('pdf_read');
    }
    
    function write() {
        $this->load->library('global_class');
        $this->load->database();
        $this->load->view('pdf_write');
    }

    function form() {
        $this->load->library('global_class');
        $this->load->database();
        $this->load->view('pdf_form');
    }
    
    
}


pdf_form.php produces a basic form (for now)

Code:
<form action="/index.php/pdf/write" method="POST" enctype="text/plain">
<input type="hidden" name="filename" value="base_form_4"/>  
<hr>78 - (Text1) - Tx  - (test1)<br>Text1: &lt;input type="text" name="Text1" value="test1"&gt;&lt;br><hr>81 - (CheckBox1) - Btn  - Yes<br>CheckBox1: &lt;input type="checkbox" name="CheckBox1" value="Yes" checked&gt; Yes<br><hr>83 - (RadioButton1) - Btn  - Yes<br>RadioButton1: &lt;input type="radio" name="RadioButton1" value="Yes" checked&gt; Yes<br><hr>84 - (RadioButton1) - Btn  - Yes<br>RadioButton1: &lt;input type="radio" name="RadioButton1" value="No"&gt; No<br><hr>85 - (ComboBox1) - Ch [[(1)(item 1)][(2)(item 2)]] / 1,item 1|2,item 2 - (2)<br>ComboBox1: <select name="ComboBox1" size="1" >

<option value="1">item 1</option>
<option value="2" selected>item 2</option>
</select>
<br><hr>86 - (Button1) - Btn  - <br>Button1: &lt;input type="checkbox" name="Button1" value="No"&gt; No<br><hr>87 - (Text2) - Tx  - (test6)<br>Text2: &lt;input type="text" name="Text2" value="test6"&gt;&lt;br><hr>88 - (ListBox1) - Ch [[(1)(List 1)][(2)(List 2)]] / 1,List 1|2,List 2 - (2)<br>ListBox1: <select name="ListBox1" size="5" >
<option value="1">List 1</option>
<option value="2" selected>List 2</option>

</select>
<br><hr>
&lt;input type="submit" name="submit" value="Post Values and Write new PDF"/&gt;  
&lt;/form&gt;

This form is to post to the write function which calls pdf_write.php

at the top of pdf_write.php is the code to iterate through the $_POST array

but it is empty


No $_POST data - El Forum - 06-04-2009

[eluser]Thorpe Obazee[/eluser]
Can you ensure that you're 'POST'-ing to the correct location?