Welcome Guest, Not a member yet? Register   Sign In
Problem with Form Validation and Htaccess file
#23

[eluser]InsiteFX[/eluser]
Dave, I set this up on my system and it runs fine coded like below with index.php removed.

./application/config/autoload.php
Add the url and form helpers.

./application/controllers/login.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ------------------------------------------------------------------------
* Created by Php Designer 8.
* Date  : 5/28/2012
* Time  : 9:50:47 PM
* Author: Raymond L King Sr.
* The Learn CodeIgniter Development Team.
*
* Class Login Controller
*
* ------------------------------------------------------------------------
* To change this template use File | Settings | File Templates.
* ------------------------------------------------------------------------
*/

class Login extends CI_Controller {

/**
  * -----------------------------------------------------------------------
  * Class variables - public, private, protected and static.
  * -----------------------------------------------------------------------
  */


// ----------------------------------------------------------------------

/**
  *  __construct
  *
  * Class Constructor PHP 5+
  *
  * @access public
  * @return void
  */
public function __construct()
{
  parent::__construct();

}

// --------------------------------------------------------------------

/**
  * index()
  *
  * Default index method.
  *
  * @access public
  * @return void
  */
public function index()
{
  $data = array(
   '' => '',
  );

  $this->load->vars($data);
  $this->load->view('login');
}

public function process_login()
{
  $this->load->library('form_validation');

  $this->form_validation->set_rules('cid', 'a', 'trim|required|xss_clean');
  $this->form_validation->set_rules('email', 'b', 'trim|required|valid_email|xss_clean');
  $this->form_validation->set_rules('pass', 'c', 'trim|required|xss_clean');

  if ($this->form_validation->run() == FALSE)
  {
   echo "false<br />";
   $this->load->view('login', 'refresh');
  }
  else
  {
   echo "ok<br />";
   var_dump($this->input->post(NULL, TRUE));
   exit;
  }
}
}

/* ------------------------------------------------------------------------
* End of file login.php
* Location: ./application/controllers/login.php
* ------------------------------------------------------------------------
*/

./application/views/login.php
Code:
<div id="LoginContainer">
&lt;?php echo form_open('login/process_login');?&gt;

<h1>Login</h1>

<div id="LoginContainerRow">
  <div id="LoginContainerLabel">Account No:</div>
  <div id="LoginContainerInput">
   &lt;input type="text" name="cid" /&gt;
  </div>
    </div>

<div id="LoginContainerRow">
  <div id="LoginContainerLabel">Email Address:</div>
        <div id="LoginContainerInput">
   &lt;input type="text" name="email" /&gt;
  </div>
    </div>

<div id="LoginContainerRow">
  <div id="LoginContainerLabel">Password:</div>
        <div id="LoginContainerInput">
   &lt;input type="password" name="pass" /&gt;
  </div>
    </div>

    <div id="LoginContainerButton">
  &lt;input name="Submit" type="submit" value="Log In"/&gt;
    </div>

&lt;?php echo form_close(); ?&gt;
</div>

Code:
// link keyed into browser
http://localhost/apptesting/login

// and the var_dump
okarray(4) { ["cid"]=> string(3) "300" ["email"]=> string(13) "[email protected]" ["pass"]=> string(6) "202020" ["Submit"]=> string(6) "Log In" }


I think it was trying to use the url_helper before it was loaded...
Or because the input submit was missing the name=""


Messages In This Thread
Problem with Form Validation and Htaccess file - by El Forum - 05-27-2012, 05:00 AM
Problem with Form Validation and Htaccess file - by El Forum - 05-27-2012, 11:00 AM
Problem with Form Validation and Htaccess file - by El Forum - 05-27-2012, 03:12 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 02:02 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 02:15 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 02:20 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 02:37 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 02:40 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 03:26 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 03:33 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 03:40 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 03:46 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 03:48 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 03:50 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 03:53 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 03:55 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 03:57 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 03:58 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 03:59 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 04:02 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 04:03 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 04:25 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 07:21 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 08:01 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-28-2012, 08:25 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-29-2012, 01:27 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-29-2012, 04:15 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-29-2012, 06:16 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-29-2012, 06:43 PM
Problem with Form Validation and Htaccess file - by El Forum - 05-30-2012, 12:52 AM
Problem with Form Validation and Htaccess file - by El Forum - 05-30-2012, 02:07 AM
Problem with Form Validation and Htaccess file - by El Forum - 05-30-2012, 08:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB