Welcome Guest, Not a member yet? Register   Sign In
how to insert a current date into a database
#3

[eluser]m4d3 Gun[/eluser]
wish this can help u....


//front controller

<?
function save(){
if($this->input->post('submit')){
$now = date('Y-m-d H:iConfused'); //here u can set the datetime
$data = array(
'name'=>$this->input->post('name'),
'address'=>$this->input->post('address'),
'ts_created'=>$now
);

$this->db->insert('userdtails',$data)
redirect('front/index','refresh');

?>


//than in the view

<?

<?=form_open('front/save');?>
<table width="522">
<tr>
<td width="138">Name</td>
<td width="372">
&lt;input name="name" size="30" type="text" /&gt;&lt;/td>
</tr>

<tr>
<td width="138">Address</td>
<td width="372">
&lt;input name="address" size="30" type="text" /&gt;&lt;/td>
</tr>
<p>&lt;input name="submit" type="submit" value="Save" /&gt;&lt;/p>
</table>
&lt;/form&gt;
?&gt;


Messages In This Thread
how to insert a current date into a database - by El Forum - 09-15-2009, 11:50 PM
how to insert a current date into a database - by El Forum - 09-16-2009, 12:22 AM
how to insert a current date into a database - by El Forum - 09-16-2009, 12:39 AM
how to insert a current date into a database - by El Forum - 09-16-2009, 02:08 AM
how to insert a current date into a database - by El Forum - 09-16-2009, 03:55 AM
how to insert a current date into a database - by El Forum - 09-16-2009, 08:50 AM
how to insert a current date into a database - by El Forum - 09-16-2009, 10:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB