Welcome Guest, Not a member yet? Register   Sign In
Reciving post data in a array then printing out in a view again
#3

[eluser]Evil Wizard[/eluser]
Code:
<li>
<label for="Title">Title<em> <img src="http://somesite/ci/assets/images/required_star.gif"
alt="required" /></em>&lt;?php echo form_error('customer[title][]'); ?&gt;</label>
<select name="customer[title][]">
<option value="" &lt;?php echo set_select('customer[title][]', '', TRUE); ?&gt; >Select a Title</option>
<option value="mr" &lt;?php echo set_select('customer[title][]', 'mr'); ?&gt; >Mr</option>
<option value="ms" &lt;?php echo set_select('customer[title][]', 'ms'); ?&gt; >Ms</option>
<option value="mrs" &lt;?php echo set_select('customer[title][]', 'mrs'); ?&gt; >Mrs</option>
<option value="miss" &lt;?php echo set_select('customer[title][]', 'miss'); ?&gt; >Miss</option>
</select>
</li>
Code:
&lt;?php
class Form extends Controller {

        function index()
        {
        $this->load->helper('form');
        $this->load->helper('url');
        $this->load->helper('array');
        $this->load->helper('html');
        $this->load->helper('date');
        $this->load->library('form_validation');
        $this->load->library('email');

// Cant seem to get post data with these
/*        $data['title'] = $_POST['customer[title]'];
        $data['title'] = $_POST['title'];
        $data_title = $_POST['customer[title]'];
*/
    // I think that will work
    $data['customer']['title'] = $this->input->post('title');
    // This should bring back the $_POST['customer'] value even if it is an array
     $data['customer'] = $this->input->post('customer');  
    
    if ($this->form_validation->run('booking') == FALSE)
        {
        $data['title'] = "";
        $data['message'] = "";
        $this->load->view('myform' , $data);
        }
        else
        {
// This below line was a test to try and populate the array element :(
        $data['title'] = "$data_title";
        $data['message'] = "Thank you, your booking has been sent!";
        $this->load->view('myform' , $data);
        }

    } // Close Function
I hope that helps


Messages In This Thread
Reciving post data in a array then printing out in a view again - by El Forum - 06-03-2009, 07:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB