Welcome Guest, Not a member yet? Register   Sign In
Trouble Getting Form to Validate
#3

[eluser]mohsin917[/eluser]
Try this one, this is the easy way..

also read the form validation user guid

contact.php controller
Code:
<?php

class Contact extends Controller {
    
    function index()
    {
        $this->load->helper(array('form', 'url'));
        
        $this->load->library('form_validation');
                
        $this->form_validation->set_rules('username', 'Username', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');
        $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
        $this->form_validation->set_rules('email', 'Email', 'required');

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

contact_view.php view file
Code:
<html>
<head>
<title>My Form</title>
</head>
<body>

<?php echo validation_errors(); ?>

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

<h5>Username</h5>
&lt;input type="text" name="username" value="" size="50" /&gt;

<h5>Password</h5>
&lt;input type="text" name="password" value="" size="50" /&gt;

<h5>Password Confirm</h5>
&lt;input type="text" name="passconf" value="" size="50" /&gt;

<h5>Email Address</h5>
&lt;input type="text" name="email" value="" size="50" /&gt;

<div>&lt;input type="submit" value="Submit" /&gt;&lt;/div>

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;


Messages In This Thread
Trouble Getting Form to Validate - by El Forum - 02-23-2010, 12:13 PM
Trouble Getting Form to Validate - by El Forum - 02-23-2010, 12:47 PM
Trouble Getting Form to Validate - by El Forum - 02-23-2010, 12:57 PM
Trouble Getting Form to Validate - by El Forum - 02-23-2010, 01:03 PM
Trouble Getting Form to Validate - by El Forum - 02-23-2010, 01:15 PM
Trouble Getting Form to Validate - by El Forum - 02-23-2010, 03:24 PM
Trouble Getting Form to Validate - by El Forum - 02-23-2010, 05:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB