[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">
<?php echo form_open('login/process_login');?>
<h1>Login</h1>
<div id="LoginContainerRow">
<div id="LoginContainerLabel">Account No:</div>
<div id="LoginContainerInput">
<input type="text" name="cid" />
</div>
</div>
<div id="LoginContainerRow">
<div id="LoginContainerLabel">Email Address:</div>
<div id="LoginContainerInput">
<input type="text" name="email" />
</div>
</div>
<div id="LoginContainerRow">
<div id="LoginContainerLabel">Password:</div>
<div id="LoginContainerInput">
<input type="password" name="pass" />
</div>
</div>
<div id="LoginContainerButton">
<input name="Submit" type="submit" value="Log In"/>
</div>
<?php echo form_close(); ?>
</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=""