Welcome Guest, Not a member yet? Register   Sign In
Input fields are coming up empty
#1

[eluser]jrock2004[/eluser]
I have been looking at this code too long and I am sure I am missing something. When I hit submit and I grab the input fields, they are empty.

View
Code:
<div id="login_form">
<h1>Login</h1>
    &lt;?php
echo form_open('admin/validate_credentials');
echo form_input('username', 'Username');
echo form_password('password', 'Password');
echo form_submit('submit', 'Login');
    ?&gt;
</div>&lt;!-- end login_form--&gt;

Controller
Code:
public function index() {
  $this->load->library('session');
  $this->load->helper('form');

  $data['content'] = 'admin/login';

        $this->load->view('admin/template.php', $data);
}

function validate_credentials() {
  $this->load->helper('form');
  $this->load->library('session');
  $this->load->model('membership');
  $query = $this->membership->validate();
  
  if($query) { // if the user's credentials validated...
   $data = array(
    'username' => $this->input->post('username'),
    'is_logged_in' => true
   );
   $this->session->set_userdata($data);
   redirect('adminArea/main');
  }
  else { // incorrect username or password
   $this->index();
   echo "Login failed" . $this->input->post('username');
  }
}

Thanks for any help
#2

[eluser]InsiteFX[/eluser]
Your missing your form_close()

Also see the Form_Validation Class Library...
CodeIgniter Users Guide - Form Validation
#3

[eluser]jrock2004[/eluser]
Added the following and still not working

Code:
<div id="login_form">
<h1>Login</h1>
    &lt;?php
  echo form_open('admin/validate_credentials');
  echo form_input('username', 'Username');
  echo form_password('password', 'Password');
  echo form_submit('submit', 'Login');
  echo form_close();
?&gt;
</div>&lt;!-- end login_form--&gt;
#4

[eluser]Mauricio de Abreu Antunes[/eluser]
Please, print your array post with:
Code:
print_r($_POST);
#5

[eluser]jrock2004[/eluser]
The array comes up empty

Array ( )
#6

[eluser]Mauricio de Abreu Antunes[/eluser]
Paste the code here, please.
#7

[eluser]InsiteFX[/eluser]
You are re-loading the session and form_helper in your validate_credentials() method, no need to do this
just autoload them in ./application/config/autoload.php
#8

[eluser]jrock2004[/eluser]
I have pasted the code in my first post. What else are you looking for?


Also, I should add that this code is running on my localhost via a wamp server. I am starting to see via google searches with people who are having similar issues
#9

[eluser]Mauricio de Abreu Antunes[/eluser]
Paste your print_r.
#10

[eluser]jrock2004[/eluser]
Here it is from chrome inspector

Code:
Array
(
)




Theme © iAndrew 2016 - Forum software by © MyBB