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

[eluser]ken kloud[/eluser]
this form is from the user guide in form validation:


myform.php

<html>
<head>
<title>My Form</title>
</head>
<body>

<?=$this->validation->error_string; ?>

<?=form_open('form'); ?>

<h5>Username</h5>
&lt;input type="text" name="username" value="&lt;?=$this-&gt;validation->username;?&gt;" size="50" />

<h5>Password</h5>
&lt;input type="text" name="password" value="&lt;?=$this-&gt;validation->password;?&gt;" size="50" />

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

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

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

&lt;/form&gt;

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



form.php -controller

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

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

$rules['username'] = "required";
$rules['password'] = "required";
$rules['passconf'] = "required";
$rules['email'] = "required";

$this->validation->set_rules($rules);

$fields['username'] = 'Username';
$fields['password'] = 'Password';
$fields['passconf'] = 'Password Confirmation';
$fields['email'] = 'Email Address';

$this->validation->set_fields($fields);

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



myformsuccess.php

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

<h3>Your form was successfully submitted!</h3>

<p>&lt;?=anchor('form', 'Try it again!'); ?&gt;</p>

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



+++++++++++++++++++++++++++++

This is my following errors in the browser:

browser:

validation->error_string; ?&gt;

then in every fields of the textbox the php code will see: example:&lt;?=$this->validation->username;?&gt;
this code is in the textbox...

and my problem is if i'am doing right,, because this code did not run,, but in the user guide its run very clear to understand but in testing it, its not...

sorry for this silly question...
thank you for the replys...


Messages In This Thread
form validation: - by El Forum - 01-24-2008, 03:35 AM
form validation: - by El Forum - 01-24-2008, 03:39 AM
form validation: - by El Forum - 01-24-2008, 05:07 AM
form validation: - by El Forum - 01-24-2008, 05:23 AM
form validation: - by El Forum - 01-24-2008, 05:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB