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

[eluser]jrock2004[/eluser]
Ok so I thought I would kinda start this over. So with reading the form validation helper I came up with this

autoload
Code:
$autoload['libraries'] = array('database', 'session');
$autoload['helper'] = array('url', 'html', 'form');

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');
  echo form_close();
  echo validation_errors();
?&gt;
</div>&lt;!-- end login_form--&gt;

controller
Code:
function __construct() {
        parent::__construct();
    }

    function index() {
     $data['content'] = 'admin/login';
     $this->load->view('admin/template.php', $data);
    }

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

     $this->form_validation->set_rules('username', 'Username', 'trim|required');
     $this->form_validation->set_rules('password', 'Password', 'trim|required');

     if($this->form_validation->run() == FALSE) {
       print_r($_POST);
       $this->load->view('admin/login');
     } else {
      redirect('home', 'refresh');
     }
    }

With this code, when I hit submit it is reloading the login page. I do not see any errors. And POST is empty.
#12

[eluser]aquary[/eluser]
InsiteFX, those are not related to his problem.... If he doesn't know they are not related, he'll waste the time trying to fix his code with your unrelated advice.

jrock2004, please also check and post your form's generated HTML code, and maybe the validate() function inside thye model. Maybe the posted values got altered along the way. Also, you can try put the print_r($_POST); as the first line of index.php. If you saw something there, the problem should be in your PHP/CI code, else, it's in the form.
#13

[eluser]jrock2004[/eluser]
Ok, I have found what is happening here. So after some googling, I decided to empty out my .htaccess file which brings back the index.php to my url. Now when I try my code it works. So now I need to figure out what I did to cause this issue. Here is my htaccess file

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

    # These are the external sites that are not being ran by code ignitier
    RewriteCond %{REQUEST_FILENAME} ^update [NC]
    RewriteRule .* index.php/$0 [PT,L]

    RewriteCond %{REQUEST_FILENAME} ^blog [NC]
    RewriteRule .* index.php/$0 [PT,L]

    RewriteCond %{REQUEST_FILENAME} ^compadv [NC]
    RewriteRule .* index.php/$0 [PT,L]

    RewriteCond %{REQUEST_FILENAME} ^gatormemories [NC]
    RewriteRule .* index.php/$0 [PT,L]

    RewriteCond %{REQUEST_FILENAME} ^library [NC]
    RewriteRule .* index.php/$0 [PT,L]

    RewriteCond %{REQUEST_FILENAME} ^updates [NC]
    RewriteRule .* index.php/$0 [PT,L]

</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>
#14

[eluser]jrock2004[/eluser]
I found the solution. It appears that my mod_rewrite was turned off. I was surprised that not having the index.php in the url was working with that disabled. So that was the whole problem. Thanks guys
#15

[eluser]Mauricio de Abreu Antunes[/eluser]
You are welcome!




Theme © iAndrew 2016 - Forum software by © MyBB