代码点火器“未指定输入文件”提交表单时出错


Codeigniter "No input file specified." error when submitting form?

我被困住了,似乎无法弄清楚我的问题。我第一次尝试使用Codeigniter编写基本的"联系我们表格"。我的观点上的表格看起来像这样。

<div style='float: left; padding-right: 55px; padding-left: 35px;'>
    <?php 
        $this->load->helper('form'); 
        echo form_open('pages/emailsender'); ?>
        Contact Us:<br />
        <?php 
        echo form_input('name', 'Enter Your Name');
        echo form_input('email', 'Enter Your Email'); 
        echo "<br />";
        echo form_textarea('message', 'Enter your message here, thanks for taking the time to contact us!');
        echo "<br />";
        echo form_submit('submit', 'Send Message!');
        echo form_reset('reset', 'Reset Form');
        echo form_close();
        ?>
</div>

我的控制器页面.php看起来像这样。

<?php
class Pages extends CI_Controller {
    public function index(){
        $this->load->view('templates/header');
        $this->load->view('home');
        $this->load->view('templates/footer');
    }
    public function home(){
        $this->load->view('templates/header');
        $this->load->view('home');
        $this->load->view('templates/footer');
    }
    public function about(){
        $this->load->view('templates/header');
        $this->load->view('about');
        $this->load->view('templates/footer');
    }
    public function services(){
        $this->load->view('templates/header');
        $this->load->view('services');
        $this->load->view('templates/footer');
    }
    public function reviews(){
        $this->load->view('templates/header');
        $this->load->view('reviews');
        $this->load->view('templates/footer');
    }
    public function specials(){
        $this->load->view('templates/header');
        $this->load->view('specials');
        $this->load->view('templates/footer');
    }
    public function contact(){
        $this->load->view('templates/header');
        $this->load->view('contact');
        $this->load->view('templates/footer');
    }
    public function emailsender(){
        $this->load->view('templates/header');
        $this->load->view('contact');
        $this->load->view('templates/footer');
    }
}

有"电子邮件发件人"功能只是将我重定向回测试的同一页面,但它甚至不会这样做?!我每次都收到"未指定输入文件"错误。我在堆栈溢出代码点火器上阅读了这篇文章,没有指定输入文件错误,但它似乎没有解决我的问题。我的配置文件看起来像这样。

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|   http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = 'http://mywebsitename.com';
$config['index_page'] = ""; 
$config['uri_protocol'] = "AUTO"; 

知道为什么我收到"未指定输入文件"错误的任何想法?

.htaccess更改为如下所示

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

请注意最后一行中的?标记。以前这条线是这样的RewriteRule ^(.*)$ index.php/$1 [L]

此外,请确保在.htaccess中添加此行RewriteBase /

像这样更改您的 .htaccess

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>

希望它能为你工作...谢谢

更改:

 echo form_open('pages/emailsender'); ?>

自:

echo form_open_multipart('pages/emailsender'); ?>

form_open_multipartenctype="multipart/form-data"添加到form标记。

您需要使用直接链接而不是表单打开标签的简写。喜欢这个:

echo form_open(‘http://example.com/welcome/emailsender’);

取而代之的是:

echo form_open(‘welcome/emailsender’);