我被困住了,似乎无法解决我的问题。我正在尝试首次使用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";
为什么我收到No input file指定错误的任何想法?
答案 0 :(得分:7)
将您的.htaccess
更改为
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
请注意最后一行中的?
标记。以前这一行就是这样的RewriteRule ^(.*)$ index.php/$1 [L]
另外,请务必在RewriteBase /
.htaccess
答案 1 :(得分: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>
希望它对你有用...... 感谢
答案 2 :(得分:0)
变化:
echo form_open('pages/emailsender'); ?>
要:
echo form_open_multipart('pages/emailsender'); ?>
form_open_multipart
将enctype="multipart/form-data"
添加到form
代码。
答案 3 :(得分:0)
您需要使用直接链接而不是表单打开标记的简写。像这样:
echo form_open(‘http://example.com/welcome/emailsender’);
而不是:
echo form_open(‘welcome/emailsender’);