[eluser]Unknown[/eluser]
Hello every one...
I have just started using CodeIgniter..I have been receiving the following error and I don't understand why...Please help
Fatal error: Call to undefined function form_label() in /opt/lampp/htdocs/ci_demo/system/application/views/template.php on line 13
My controller file is
blog.php
<?php
class Blog extends Controller
{
function Blog()
{
parent::Controller();
$this->load->helper('form','url');
}
function addContact()
{
$this->load->helper('url');
$this->load->model('mcontacts','',TRUE);
$this->mclasses->addContact();
$this->index();
//redirect('blog/index');
}
function index()
{
$this->load->helper('html');
$this->load->model('mcontacts','',TRUE);
$showres['x']= $this->mcontacts->showContact();
$this->load->vars($showres);
$this->load->view('template');
}
}
My model file is
mcontacts.php
<?php
class Mcontacts extends Model
{
function Mcontacts()
{
parent::Model();
}
function addContact()
{
$data=array(
'name'=>$this->input->xss_clean($this->input->post('name')),
'email'=>$this->input->xss_clean($this->input->post('email')),
'notes'=>$this->input->xss_clean($this->input->post('notes'))
);
$this->db->insert('mujahid',$data);
}
function showContact()
{
$query= $this->db->query("select name,email,notes from contacts");
$res = $query->result_array();
}
}
?>
And my views file is
template.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html >
<body>
<table border="1">
<?php
echo form_open('blog/addContact');
?>
<tr>
<td>
<?php echo form_label('name','name');?></td><td>
<?php $ndata=array('name'=>'name', 'id'=>'id','size'=>'25');
echo form_input($ndata);
?>
</td></tr>
<tr>
<td><?php echo form_label('Email Address','email');?></td>
<?php $emdata=array('name'=>'email', 'id'=>'id','size'=>'25','value'=>'Please enter ur gmail id');
echo form_input($emdata);
?>
</td></tr>
<td><?php echo form_label('Notes','notes');?></td>
<?php $ntdata=array('name'=>'notes', 'id'=>'id','size'=>'25','value'=>'Please enter ur comments');
echo form_input($ntdata);
?>
</td></tr>
<tr>
<td colspan="2"><center><?php echo form_submit('submit','OK');
echo form_close();
?>
</td>
</tr></table>
<table border="1">
<tr><th>Name</th><th>Email</th><th>Notes</th></tr>
<?php
foreach($x as $row)
{
?>
<tr>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['email'];?></td>
<td><?php echo $row['notes'];?></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
I didn't have to post the model file but it is just a demo...