简体   繁体   中英

Codeigniter “No input file specified.” error when submitting form?

I am stuck and cannot seem to figure my issue out. I am trying to write a basic "Contact Us Form" using Codeigniter for the first time. My form on my view looks like this..

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

and my controller pages.php looks like this..

<?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');
    }

}

I have the "emailsender" function just redirecting me back to the same page as a test, but it won't even do that?! I get a "No input file specified." error every time. I read this post on stackoverflow Codeigniter no input file specified error but it doesn't seem to resolve my issue. My config file looks like this..

/*
|--------------------------------------------------------------------------
| 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"; 

any ideas why I am getting the No input file specified error?

Change your .htaccess to look like this

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

Notice the ? mark in the last line. Previously this line was something like this RewriteRule ^(.*)$ index.php/$1 [L]

Also make sure to add this line RewriteBase / in your .htaccess

Change Your .htaccess like that

<IfModule mod_rewrite.c>

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

</IfModule>

Hope It will works for you... thanks

Change:

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

To:

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

form_open_multipart adds the enctype="multipart/form-data" to the form tag.

You need to use the direct link instead of the short hand of the form open tag. Like this:

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

instead of this:

echo form_open(‘welcome/emailsender’);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM