CodeIgniter Forums
min_length ignore - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: min_length ignore (/thread-53214.html)



min_length ignore - El Forum - 07-15-2012

[eluser]Unknown[/eluser]
when someone on the site less than the maximum length specified still get the message posted and the error appears while the post portion on the side is TRUE, and not on the False side of the script. the False side of the script you see.

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Gasteboek extends CI_Controller {

public function test()
{
  $this->load->helper(array('form', 'url'));
  $this->load->helper('html');
  $this->load->library('form_validation');
  //$this->form_validation->set_rules('username', 'Username', 'required');
  $this->form_validation->set_rules('naam', 'Naam', 'trim|alpha|required|min_length[3]|max_length[16]|xss_clean');
  $this->form_validation->set_rules('bericht', 'Bericht', 'trim|required|min_length[5]|max_length[500]|xss_clean');
  

  if ($this->form_validation->run() == FALSE)
  {
   //echo CI_VERSION;
   $this->load->view('gasteboek2');
  }
  else
  {
   function ubb($string) {
    $string = nl2br($string); // Zorgen dat er meerdere regels gebruikt kunnen worden
    $string = preg_replace("#\[b\](.+?)\[/b\]#is", "<b>\\1</b>", $string); // [b][/b] => <b></b>
    $string = preg_replace("#\[i\](.+?)\[/i\]#is", "<i>\\1</i>", $string); // [i][/i] => <i></i>
    $string = preg_replace("#\[u\](.+?)\[/u\]#is", "<u>\\1</u>", $string); // [u][/u] => <u></u>
    $string = preg_replace("#\[s\](.+?)\[/s\]#is", "<s>\\1</s>", $string); // [s][/s] => <s></s>
    
    return $string;
   }
   $gasteboek = "INSERT INTO gastenboek (naam, bericht, datum, ip) VALUES ('".trim(mysql_real_escape_string(set_value('naam', TRUE)))."', '".trim(mysql_real_escape_string(set_value('bericht', TRUE)))."', NOW(), '".mysql_real_escape_string($this->input->ip_address())."')";
   $this->db->query($gasteboek);
   echo 'U bericht is verzonden met succes';
   $sql = $this->db->query("SELECT * FROM gastenboek ORDER BY datum DESC");
   if ($sql->num_rows() == 0) {
    // Als er nog geen reacties geplaatst zijn
    echo 'We hebben nog geen reacties!';
   } else {
    foreach ($sql->result() as $row)
      {
      echo '<b>Naam:</b>';
      echo $row->naam;
      echo br();
      echo '<b>Datum:</b>';
      echo $row->datum;
      echo br();
      echo '<b>Bericht</b>';
      echo br();
      echo $row->bericht;
      echo br();
     }
   }
  }
  //$this->load->view('gasteboek2', $data);
}
}