0

SOLUTION: I used WAMP server on my VPS. The problem was the rewrite module was not loaded in the apache settings. I fixed this by going into my apache folder/conf/http.conf and removing the hashtag infront of this line: LoadModule rewrite_module modules/mod_rewrite.so. I restarted apache and it worked.

EDIT: It's not running even tho i input an email and password. I am not being able to run the form_validation at all it seems.

EDIT 2: Also found out i can't echo $this->input->post('email'); in the function login_validation.

EDIT 3: I echoed out $this->output->enable_profiler(); and it said i sent no post data. Is it possible that my .htaccess is doing something with the posting?

i'm creating a login / registration system using codeigniter. I got it to work on localhost but something must have happened when i moved it to my host.

I autoload form in my autoload.php:

$autoload['helper'] = array('form', 'url');

This is my validation code in class Main file controllers/main.php:

public function login_validation(){

    $this->load->library('form_validation');

    $this->form_validation->set_rules('email', 'Email', 'required');
    $this->form_validation->set_rules('password', 'Password', 'required|md5');

    if($this->form_validation->run()){
        //NO VALIDATION ERRORS
    }else{
        echo 'Errors:<br />';
        echo validation_errors();
    }
}

My form:

<?php 
echo form_open('main/login_validation');

$property_type = array('class' => 'bar left', 'value' => 'E-Mail', 'name' => 'email');
echo form_input($property_type);

$property_type = array('class' => 'bar right', 'value' => 'Password', 'name' => 'password');
echo form_password($property_type);

$property_type = array('class' => 'buttonone', 'value' => 'Login', 'name' => 'login_submit');
echo form_submit($property_type);

echo form_close(); 
?>

When i dont type in anything in the form it should display Email and password is required. It only says Errors:. But it does not display the validation errors.

I also had to change to another .htaccess when i uploaded it to my host.

This is my new htaccess:

  <IfModule mod_rewrite.c>
  RewriteEngine On
  # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
  #  slashes.
  # If your page resides at
  #  http://www.example.com/mypage/test1
  # then use
  # RewriteBase /mypage/test1/
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [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>

This is my old .htaccess:

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 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]    

2 Answers 2

0

just check the if condition and put form error function in to view page

public function login_validation(){

    $this->load->library('form_validation');

    $this->form_validation->set_rules('email', 'Email', 'required');
    $this->form_validation->set_rules('password', 'Password', 'required|md5');

      if ($this->form_validation->run($this) !== FALSE) //write like this if condition
      { 
        //NO VALIDATION ERRORS
    }else{
        echo 'Errors:<br />';
        echo validation_errors();
    }
}

your view page put in to this

<?php echo validation_errors(); ?>

more refer this http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html

Sign up to request clarification or add additional context in comments.

Comments

0

I used WAMP server on my VPS. The problem was the rewrite module was not loaded in the apache settings. I fixed this by going into my apache folder/conf/http.conf and removing the hashtag infront of this line: LoadModule rewrite_module modules/mod_rewrite.so. I restarted apache and it worked.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.