Welcome Guest, Not a member yet? Register   Sign In
need with date input?
#1

[eluser]newbie boy[/eluser]
how can i pass the date input from my html code which has 3 inputs: day: month: year: to mysql database which only has one field, the date field. thanks!
#2

[eluser]Aken[/eluser]
What format do you want your date to be in the database?

The PHP function mktime() allows you to create a unix time stamp based on time/date variables.
#3

[eluser]newbie boy[/eluser]
YYYY-MM-DD formtat!
#4

[eluser]newbie boy[/eluser]
actually i can already input it on my database but the value would always be 0000-00-00, instead of the date i actually input on it from the html form.
#5

[eluser]Aken[/eluser]
Well you could just put the form values together...

If you're using POST to submit the form...
Code:
$date = $this->input->post('year').'-'.$this->input->post('month').'-'.$this->input->post('day');

Then use the $date variable in your query. Pretty simple.
#6

[eluser]newbie boy[/eluser]
hey aken, that's exactly my code but still the output is 0000-00-00, instead of the actual date input.
#7

[eluser]Aken[/eluser]
Post your controller code and I'll take a look. (Make sure to use the code tags plz!)
#8

[eluser]newbie boy[/eluser]
i'm sorry aken, i dont know how to do the tagz, but here's my code

my model:
public function addMember($email,$birthday) {

$this->email = $email;
$this->birthday = $birthday;
$this->save(); }

my controller:
public function registerMember() {

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

$UserModel = new UserModel();
$UserModel->addMember($email,$birthday);

echo $birthday; }

thanks for the time.
#9

[eluser]Aken[/eluser]
What does your save() function consist of? (btw, hit the 'code' button above and paste your code inside it to get nice formatting like I had before)
#10

[eluser]newbie boy[/eluser]
Code:
my model:
public function addMember($email,$birthday) {
            
$this->email   =  $email;
$this->birthday   =  $birthday;
$this->save();                    }

my controller:
public function registerMember() {

$email       =  $this->input->post(‘email’);
$birthday   =    $this->input->post(‘year’).”-”.$this->input->post(‘month’).”-”.$this->input->post(‘day’);
      
$UserModel   = new UserModel();
$UserModel->addMember($email,$birthday);

echo $birthday; }

hey, aken, it is actually working now! I just need to refresh my localhost add. I really appreciate your time. i hope you will always help those newbies like me and that there will be more like you who are willing to help. thanks! God bless!!!




Theme © iAndrew 2016 - Forum software by © MyBB