Welcome Guest, Not a member yet? Register   Sign In
validation_errors is empty
#1

[eluser]Unknown[/eluser]
Hi all

I've tried to debug a strange behaviour for the last 5 hours and I guess I need some help now Sad It must be something completely obvious but I just cannot see it...

I have one controller which returns FALSE upon $this->form_validation->run().
However, it returns an empty validation_errors string and hence no error message.

- I have another controller that is working perfectly
- If I supply correct values, the form is submitted successfully.

so this is my view:

Code:
<html>
<head>
<title>Register</title>
</head>
<body>
<h1>Register</h1>

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

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

<h5>Username*</h5>
&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?&gt;" size="50" /&gt;
<h5>Password*</h5>
&lt;input type="password" name="password" value="&lt;?php echo set_value('password'); ?&gt;" size="50"/&gt;
<h5>Confirm Password*</h5>
&lt;input type="password" name="passconf" value="&lt;?php echo set_value('passconf'); ?&gt;" size="50" type ="password"/&gt;
<h5>Email*</h5>
&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?&gt;" size="50" value=""/&gt;
<h5>Re-type Email*</h5>
&lt;input type="text" name="emailconf" value="&lt;?php echo set_value('emailconf'); ?&gt;" size="50" value=""/&gt;
<h5>First Name</h5>
&lt;input type="text" name="fname" value="&lt;?php echo set_value('fname'); ?&gt;" size="50" value=""/&gt;
<h5>Last Name</h5>
&lt;input type="text" name="lname" value="&lt;?php echo set_value('lname'); ?&gt;" size="50" value=""/&gt;
<h5>Company Name</h5>
&lt;input type="text" name="cname" value="&lt;?php echo set_value('cname'); ?&gt;" size="50" value=""/&gt;

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

&lt;/form&gt;

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

And this is my controller (I have only one validation rule left for debugging...):

Code:
&lt;?php

class Registration extends CI_Controller
{

public function __construct()
{
  parent::__construct();

  // make sure user is really not logged in
  $acc_id = $this->session->userdata('account_id');
  if ( ! empty($acc_id) ) { redirect( 'mypage', 'refresh'); }
}

function index()
{

  $this->load->helper(array('form'));
  $this->load->library('form_validation');
  
  $this->form_validation->set_rules('username', 'Username', 'required');
  if ($this->form_validation->run() == FALSE)
  {
   $this->load->view('registration_1_vw');
  }  
  else
  {
   [... removed, because this is working ...]
         }
}




Theme © iAndrew 2016 - Forum software by © MyBB