I've been stuck here for hours and I can not seem to find the source.
I have a simple login form.
Code:
<form method="post" class="m-t" role="form" action="<?php echo base_url();?>login/">
<div class="form-group">
<input type="text" name="username" id="username" class="form-control" placeholder="Username" required="">
</div>
<div class="form-group">
<input type="password" name="password" id="password" class="form-control" placeholder="Password" required="">
</div>
<button type="submit" class="btn btn-primary block full-width m-b">Login</button>
<a href="#"><small>Forgot password?</small></a>
<p class="text-muted text-center"><small>Do not have an account?</small></p>
<!-- <a class="btn btn-sm btn-white btn-block" href="register.html">Create an account</a> -->
</form>
The Controller I am Posting to looks like this:
PHP Code:
class Login extends CI_Controller {
public function _construct()
{
session_start();
parent::__construct();
}
public function index()
{
$check = $this->session->userdata('logged_in');
if(empty($check))
{
$this->load->view('templates/header.php');
$this->load->view('pages/home');
$this->load->view('templates/header.php');
}
else
{
$st = $this->session->userdata('role');
if($st=='worker')
{
header('location:'.base_url().'worker');
}
else if($st=='client')
{
header('location:'.base_url().'client');
}
else if($st=='sales')
{
header('location:'.base_url().'sales');
}
else if($st=='billing')
{
header('location:'.base_url().'billing');
}
}
}
public function login()
{
print_r($_POST);
$u = $this->input->post('username');
$p = $this->input->post('password');
$this->web_app_model->getLoginData($u, $p);
}
}
The POST DATA is in the array yet I get the following errors.
Quote:class Login extends CI_Controller {
public function _construct()
{
session_start();
parent::__construct();
}
public function index()
{
$check = $this->session->userdata('logged_in');
if(empty($check))
{
$this->load->view('templates/header.php');
$this->load->view('pages/home');
$this->load->view('templates/header.php');
}
else
{
$st = $this->session->userdata('role');
if($st=='worker')
{
header('location:'.base_url().'worker');
}
else if($st=='client')
{
header('location:'.base_url().'client');
}
else if($st=='sales')
{
header('location:'.base_url().'sales');
}
else if($st=='billing')
{
header('location:'.base_url().'billing');
}
}
}
public function login()
{
print_r($_POST);
$u = $this->input->post('username');
$p = $this->input->post('password');
$this->web_app_model->getLoginData($u, $p);
}
}
Quote:A PHP Error was encountered
Severity: Error
Message: Call to a member function post() on null
Filename: controllers/Login.php
Line Number: 46
Backtrace:
I tried directly accessing the post data via $_POST as shown here:
PHP Code:
public function login()
{
print_r($_POST);
//$u = $this->input->post('username');
//$p = $this->input->post('password');
$u = $_POST['username'];
$p = $_POST['password'];
$this->web_app_model->getLoginData($u, $p);
}
And then I get the following errors:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Login::$web_app_model
Filename: controllers/Login.php
Line Number: 50
Backtrace:
File: C:\xampp\htdocs\mmmPortal\application\controllers\Login.php
Line: 50
Function: _error_handler
File: C:\xampp\htdocs\mmmPortal\index.php
Line: 315
Function: require_once
Quote:A PHP Error was encountered
Severity: Error
Message: Call to a member function getLoginData() on null
Filename: controllers/Login.php
Line Number: 50
Backtrace:
It seems anything that uses $this is not working yet it works in my other controllers and I've compared them over and over for basic structure errors.
Any help would be greatly appreciated!