[eluser]Unknown[/eluser]
I did it in a normal view and use a include to add in the news page
Code:
<div id="comments">
<?php
if($_POST)
{
$data['idNews'] = $this->uri->segment(3);
$data['dateHour'] = date('Y-m-d H:i:s');
$data['name'] = $this->input->post('name');
$data['email'] = $this->input->post('email');
$data['comment'] = $this->input->post('comment');
$data['ip'] = $this->input->ip_address();
$data['status'] = 0;
if($this->comments_model->add($data))
{
echo '<p> Comment add successfully!</p>';
}
}
?>
<?php
echo form_open(current_url());
echo form_label('Name: ','name');
echo br();
echo form_input('name',set_value('name');
echo br(2);
echo form_label('Email: ','email');
echo br();
echo form_input('email',set_value('email'));
echo br(2);
echo form_label('Comment: ','comment');
echo br();
echo form_textarea('comment',set_value('comment'));
echo br(2);
echo form_submit('mysubmit','Comment');
echo form_close();
?>
<?php
$this->db->order_by('id','asc');
$this->db->where('status',1);
$this->db->where('idNews',$this->uri->segment(3));
$query = $this->db->get('comments');
echo "<hr />";
if($query->num_rows() > 0)
{
foreach($query->result() as $item)
{
?>
<div class="coment">
<a href="mailto:<?php echo $item->email; ?>"><?php echo $item->name; ?></a><br />
<span><?php echo strftime('Posted %d/%m/%Y as %Hh%M', strtotime($item->dateHour)); ?></span><br />
<?php echo $item->comment; ?>
</div>
<hr />
<?php
}
}
?>
</div>
The code is working well, but when occours the post, it returns the fields with the data, I need this data disappears when occours the post.
THANKS