2013-10-11 191 views
0

我被卡住了,似乎無法解決我的問題。我正在嘗試首次使用Codeigniter編寫基本的「聯繫我們表單」。我對我的看法形式看起來像這樣..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> 

和我的控制器pages.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'); 
    } 

} 

我已在「emailsender」功能只是重定向我回到同一頁作爲測試,但它甚至不會那樣做?!我得到一個「沒有指定輸入文件」。每次都出錯。我在stackoverflow Codeigniter no input file specified error上閱讀這篇文章,但它似乎並沒有解決我的問題。我的配置文件看起來像這樣..

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

任何想法爲什麼我得到沒有輸入文件指定的錯誤?

回答

0

您需要使用的直接聯繫,而不是形式的開放標籤的手短的加入這一行RewriteBase /。就像這樣:

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

,而不是這樣的:

echo form_open(‘welcome/emailsender’); 
0

變化:

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

要:

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

form_open_multipart添加enctype="multipart/form-data"form標籤。

+0

操作不是試圖上傳表單中的文件,所以這個解決方案的確如此不是針對問題。 –

+0

感謝您提交答案,但這並未解決問題。 – ErinSKabbash

7

更改.htaccess看起來像這樣

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

通知的?馬克的最後一行。以前這條線是這樣的RewriteRule ^(.*)$ index.php/$1 [L]

同時一定要在你的.htaccess

+0

我照你說的做了,但我仍然有同樣的錯誤。我的.htaccess文件是現在!'code'RewriteEngine在 RewriteBase/ 的RewriteCond%{} REQUEST_FILENAME -f 的RewriteCond%{} REQUEST_FILENAME -d 重寫規則^ $的index.php/$ 1 [L,!(*)? QSA]'代碼'我在GoDaddy服務器上,我不知道這與它有什麼關係。但我必須對.htaccess文件進行一些更改才能讓網站甚至可以在GoDaddy上首先加載。我用你剛纔所說的替換了這些,並且該網站仍在加載,但仍然在聯繫表單上發生錯誤。 – ErinSKabbash

+0

當我點擊提交按鈕時,它會將我發送到/index.php/pages/emailsender並顯示「沒有指定輸入文件」。錯誤。 – ErinSKabbash

1

改變你的.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> 

希望它會爲你工作? 感謝