Welcome Guest, Not a member yet? Register   Sign In
form validation question
#1

[eluser]Unknown[/eluser]
Hi!

I'm having problems validating a form... And I don't know why. I don't get any value from set_values() and even if I remove all the rules I still get FALSE when I'm trying to validate it...

Here is the form:
Code:
<?php echo validation_errors(); ?>

    <?php echo form_open('contact'); ?>
    <table>
        <tr valign="top">
            <td>
    <fieldset id="perso">
        <legend>Informations Personelles</legend>
        <label for="txtNom">Votre nom:</label>&lt;input type="text" id="txtNom" value="&lt;?=set_value('txtNom'); ?&gt;" /&gt;
        <label for="txtCourriel">Votre adresse courriel:</label>&lt;input type="text" id="txtCourriel" value="&lt;?=set_value('txtCourriel'); ?&gt;" /&gt;&lt;br /><br />
            <p align="center">&lt;input type="submit" value="Envoyer" id="button" /&gt;&lt;/p>
            </fieldset>
            </td>
            <td>
    <fieldset id="message">
        <legend>Votre message</legend>
        &lt;textarea id="txtMessage"&gt;&lt;?=set_value('txtMessage'); ?&gt;&lt;/textarea&gt;
    </fieldset>
            </td>
        </tr>
    </table>
    &lt;/form&gt;

and here is the controlleR:
Code:
&lt;?php
class Contact extends Controller {

    function index()
    {
        $helpers = array('html', 'url', 'text', 'form');
        $this->load->helper($helpers);
        $data['infos'] = $this->db->get('contact');
        
        $this->load->library('form_validation');
        $this->form_validation->set_rules('txtNom', 'Votre nom', 'required');
        $this->form_validation->set_rules('txtCourriel', 'Votre adresse courriel', 'required|valid_email');
        $this->form_validation->set_rules('txtMessage', 'Votre message', 'required');

        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('contactview', $data);
        }
        else
        {
            $this->load->view('contact_successview', $data);
        }
    }
}
?&gt;

contactview is actually the form's view.

Thanks a lot!


Messages In This Thread
form validation question - by El Forum - 01-25-2009, 01:00 PM
form validation question - by El Forum - 01-25-2009, 01:29 PM
form validation question - by El Forum - 01-25-2009, 01:35 PM
form validation question - by El Forum - 01-25-2009, 03:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB