开发者

Are input->post arrays possible in codeigniter? I'm using doctrine and need to combine my birthday dropdown for db insert

I have just finished creating my signup form and now ready to insert data into the datebase using doctrine. Everything inserts fine but in my var_dump my birthday dropdown is in 3 seperates... day , month and year.. I would like to combine them and post as "birthday" into the db with doctrine.

I wish to do this in my controller, please take a look at my code and you'll see where I want to place this code.

My code:

public function submit() {

            $u = new User();
            $u->first_name = $this->input->post('first_name');
            $u->last_name = $this->input->post('first_name');
            $u->email = $this->input->post('email');
            $u->password = $this->input->post('password');
            //day
            //month
            //year
            $u->sex = $this->input->post('sex');
       开发者_如何学Go     $u->save();

            $this->load->view('submit_success'); // temporary account area page

}

}


After checking if the user has actually entered the full date, you can make a timestamp and then format it according to your db needs

$birthday = date("%d-%m-%Y", mktime(0, 0, 0, $this->input->post('month'), $this->input->post('day'), $this->input->post('year'));

Learn more on http://www.php.net/manual/en/function.date.php


For those who come across this hurdle was the solution for me:

$u->birthday = $this->input->post('year') . '-' . $this->input->post('month') . '-' . $this->input->post('day'); 

This inserted what was selected in my form using the drop down date select into my db.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜