CodeIgniter Forums
HELP Just Installed CodeIgniter, tried to validate a contact form and getting an error message!? HELP - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: HELP Just Installed CodeIgniter, tried to validate a contact form and getting an error message!? HELP (/showthread.php?tid=57970)



HELP Just Installed CodeIgniter, tried to validate a contact form and getting an error message!? HELP - El Forum - 04-30-2013

[eluser]johnny916[/eluser]

My site is sealteamrealty.com

I'm getting an error on my contact page so the HTML form elements won't even show up??

Fatal error: Call to undefined function validation_errors() in /home/johnny/public_html/sealteamrealty.com/application/views/contact.php on line 36

Here is the problem lines of code, the functions seems to be undefined but I've placed all the files where the Docs said to..

<?php echo validation_errors(); ?>

<?php echo form_open('form'); ?>


Click Contact page on my site to see what I'm talking about..




HELP Just Installed CodeIgniter, tried to validate a contact form and getting an error message!? HELP - El Forum - 04-30-2013

[eluser]Sudz[/eluser]
Have you loaded form_helper in your controller?
Post your controller code for more clearance.




HELP Just Installed CodeIgniter, tried to validate a contact form and getting an error message!? HELP - El Forum - 04-30-2013

[eluser]johnny916[/eluser]
<?php

class Form extends CI_Controller {

function index()
{
$this->load->helper(array('form', 'url'));

$this->load->library('form_validation');

$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');

if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$this->load->view('formsuccess');
}
}
}
?>


HELP Just Installed CodeIgniter, tried to validate a contact form and getting an error message!? HELP - El Forum - 05-01-2013

[eluser]Otemu[/eluser]
Hi,

Controller looks fine, can you paste your view.


HELP Just Installed CodeIgniter, tried to validate a contact form and getting an error message!? HELP - El Forum - 05-01-2013

[eluser]johnny916[/eluser]
What view? This is my contact page located in application/views/ and I named it contact.php

<?php ## Contact ?>

<h2>Contact</h2>

&lt;style&gt;

form#payment fieldset {
border: none;
margin-bottom: 10px;
}

form#payment fieldset:last-of-type {
margin-bottom: 0;
}

form#payment legend {
color: #384313;
font-size: 16px;
font-weight: bold;
padding-bottom: 10px;
text-shadow: 0 1px 1px #CCC;
}


form#payment fieldset fieldset legend {
color: #111111;
font-size: 13px;
font-weight: normal;
padding-bottom: 0;
}


&lt;/style&gt;
&lt;body&gt;

&lt;?php echo validation_errors(); ?&gt;

&lt;?php echo form_open('form'); ?&gt;

&lt;form id=payment&gt;
<fieldset>
<legend>Enter your details</legend>
<ul>
<li>
<label for=name>Name (required)</label></br>
&lt;input id=name name=name type=text placeholder="First and last name" required autofocus&gt;
</li>
<li>
<label for=email>Email (required)</label></br>
&lt;input id=email name=email type=email placeholder="[email protected]" required&gt;
</li>
<li>
<label for=phone>Phone</label></br>
&lt;input id=phone name=phone type=tel placeholder="916-396-9617"&gt;
</li>
</ul>
</fieldset>
<fieldset>
<legend>Are there a specific properties of interest?</legend>
<ul>
<li>
<label for=address>Address</label></br>
&lt;textarea id=address name=address rows=5&gt;&lt;/textarea>
</li>
<li>
<label for=postcode>Zip code</label></br>
&lt;input id=postcode name=postcode type=text&gt;
</li>
<li>
<label for=country>County</label></br>
&lt;input id=country name=country type=text&gt;
</li>
</ul>
</fieldset>
<fieldset>
<legend>How can we help you?</legend>
<ul>

<li>
<label for=address></label>
&lt;textarea id=address name=address rows=5&gt;&lt;/textarea>
</li>
<li>
</br><label for=namecard>How did you hear about us?</label></br>
&lt;input id=namecard name=namecard type=text placeholder="Google, Friend, etc..?"&gt;
</li>
</ul>
</fieldset>
<fieldset>
<button type=submit>SUBMIT</button>
</fieldset>
&lt;/form&gt;
&lt;/body&gt;



HELP Just Installed CodeIgniter, tried to validate a contact form and getting an error message!? HELP - El Forum - 05-02-2013

[eluser]Otemu[/eluser]
Hi,

I just copied your code and it works fine for me, am using Codeigniter Version 2.1.3

Thanks