Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Call to undefined function form_label()
#1

[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">

&lt;html &gt;
&lt;body&gt;
<table border="1">


&lt;?php
echo form_open('blog/addContact');
?&gt;

<tr>
<td>
&lt;?php echo form_label('name','name');?&gt;</td><td>
&lt;?php $ndata=array('name'=>'name', 'id'=>'id','size'=>'25');
echo form_input($ndata);
?&gt;
</td></tr>

<tr>
<td>&lt;?php echo form_label('Email Address','email');?&gt;</td>
&lt;?php $emdata=array('name'=>'email', 'id'=>'id','size'=>'25','value'=>'Please enter ur gmail id');
echo form_input($emdata);
?&gt;

</td></tr>


<td>&lt;?php echo form_label('Notes','notes');?&gt;</td>
&lt;?php $ntdata=array('name'=>'notes', 'id'=>'id','size'=>'25','value'=>'Please enter ur comments');
echo form_input($ntdata);
?&gt;

</td></tr>
<tr>
<td colspan="2"><center>&lt;?php echo form_submit('submit','OK');
echo form_close();
?&gt;
</td>
</tr></table>

<table border="1">
<tr><th>Name</th><th>Email</th><th>Notes</th></tr>
&lt;?php
foreach($x as $row)
{
?&gt;
<tr>
<td>&lt;?php echo $row['name']; ?&gt;</td>
<td>&lt;?php echo $row['email'];?&gt;</td>
<td>&lt;?php echo $row['notes'];?&gt;</td>
</tr>
&lt;?php
}
?&gt;
</table>
&lt;/body&gt;
&lt;/html&gt;


I didn't have to post the model file but it is just a demo...




Theme © iAndrew 2016 - Forum software by © MyBB