views:

27

answers:

1

Hi Everyone!

I am brand new to Code Igniter but I can't seem to find a way to do this in the documentation, In normal PHP you can retrieve the contents of the entire POST variable like this

$_POST = $postedVars

But I can't seem to find something that does this in the same manner, I've tried

$arr = $this->input->post;

and

$arr = $this->input->post();

With no luck! Is this possible in CI? Thanks in advance!

+1  A: 

First, you need a form or something that sets the variables Then, you retrieve them.

$this->input->post('first_name').

You are missing the name of the variable!

The signup form:

echo form_open('CHome/signup');
$data=array('name'=>'first_name', 'id'=>'first_name','size'=>40,'value'=>set_value('first_name'));
echo "<p><label for='first_name'>First Name </label>";
echo form_input($data);
echo form_submit('submit','Make Account');

The Model:

 function addUser(){
    //you should use $this->input->post('first_name')
            $data=array(
                'first_name'=>db_clean(ucfirst($_POST['first_name'])), //db_clean is a custom func
                'last_name'=>db_clean(ucfirst($_POST['last_name'])),        
                'email'=>db_clean($_POST['email']),            
                'username'=>db_clean($_POST['username']),
                'password'=>db_clean(sha1($_POST['password1'])),            
                'type'=>db_clean('user'),
            );

            $this->db->insert('users',$data);
        }

Codeigniter stores sessions in cookies, it's all weird. I suggest just using PHP's native sessions, such as $_SESSION['first_name']. Make sure to write "session_start();" in your controller/model so you can use sessions!! (usually do it in the constructor)

ggfan
Thank you much sir
Pete Herbert Penito
np! If the answer is what you are looking for, please mark it.
ggfan