Codeigniter不显示validation_errors() [英] Codeigniter not displaying validation_errors()

查看:82
本文介绍了Codeigniter不显示validation_errors()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案:我在VPS上使用了WAMP服务器。问题是apache设置中未加载重写模块。我通过进入apache文件夹/conf/http.conf并删除此行前面的#标签来解决此问题:LoadModule rewrite_module modules / mod_rewrite.so。我重新启动了apache并成功。

编辑:即使输入了电子邮件和密码,它也没有运行。我似乎根本无法运行form_validation。

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.

编辑2:还发现我无法回显$ this-> input-> post('电子邮件');在功能login_validation中。

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

编辑3:我回显了$ this-> output-> enable_profiler();它说我没有发过帖子数据。我的.htaccess是否有可能在发布信息?

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?

我正在使用codeigniter创建登录/注册系统。我可以在localhost上运行它,但是当我将其移到主机时肯定发生了某些事情。

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.

我在autoload.php中自动加载表格:

I autoload form in my autoload.php:

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

这是我在主文件控制器/main.php类中的验证代码:

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();
    }
}

我的表单:

<?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.

当我将其上传到主机时,我还不得不更改为另一个.htaccess。

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

这是我的新htaccess:

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>

这是我以前的.htaccess:

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]    


推荐答案

我在VPS上使用了WAMP服务器。问题是apache设置中未加载重写模块。我通过进入apache文件夹/conf/http.conf并删除此行前面的#标签来解决此问题:LoadModule rewrite_module modules / mod_rewrite.so。我重新启动apache并成功。

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.

这篇关于Codeigniter不显示validation_errors()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆