[eluser]Unknown[/eluser]
Hi all,
I'm using the form validation tutorial to get my forms working. I don't get errors back if I enter wrong data, and I don't get success if I enter right data.
This is what I did (exactly what the tutorial described).
Controller form.php:
Code:
<?php
class Form extends CI_Controller {
function index()
{
$this->load->helper(array('form','url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]');
$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|valid_email');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$this->load->view('formsuccess');
}
}
}
?>
View myform.php:
Code:
<html>
<head>
<title>My Form</title>
</head>
<body>
<?php echo validation_errors(); ?>
<?php echo form_open('form'); ?>
<h5>Username</h5>
<input type="text" name="username" value="" size="50" />
<h5>Password</h5>
<input type="text" name="password" value="" size="50" />
<h5>Password Confirm</h5>
<input type="text" name="passconf" value="" size="50" />
<h5>Email Address</h5>
<input type="text" name="email" value="" size="50" />
<div><input type="submit" value="Submit" /></div>
</form>
</body>
</html>
View formsuccess.php:
Code:
<html>
<head>
<title>My Form</title>
</head>
<body>
<h3>Your form was successfully submitted!</h3>
<p><?php echo anchor('form', 'Try it again!'); ?></p>
</body>
</html>
I searched everywhere for solutions, and found issue #177, but the solution from github didn't help.
In a debugging session I found in library Form_validation.php in "function set_rules" and in "function run" the following statement:
Code:
....
if (count($_POST) == 0)
{
return FALSE;
}
....
This statement always returns FALSE, even if I enter correct data in the form fields.
Can anyone help me please?
Regards,
Carmen