好的,所以我使用php和codeigniter创建了一个网站,也使用了nosql。我的所有页面都在工作,除了一个。
我检查了仪表板控制器中的所有内容,它看起来应该可以正常工作,但每当我尝试链接到页面时,我都会收到404错误,当我手动输入网址时也会发生这种情况。
关于这可能是什么的任何想法?
以下是信息中心内的内容
public function Result() {
$this->load->helper('url');
$this->load->view("site_header");
$this->load->view("site_navigation");
$this->load->view("content_result");
}
以下是从表单中的其他页面链接到的地方
<form action='content_result.php?id=1' method='post' id='quizForm' id='1'>
控制器代码:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$this->home(); }
public function home() {
$this->load->helper('url');
$this->load->view("site_header");
$this->load->view("site_navigation");
$this->load->view("content_home");
}
public function login() {
$this->load->helper('url');
$this->load->view("site_header");
$this->load->view("site_navigation");
$this->load->view("content_login");
}
public function register() {
$this->load->helper('url');
$this->load->view("site_header");
$this->load->view("site_navigation");
$this->load->view("content_register");
}
public function Quiz() {
$this->load->helper('url');
$this->load->view("site_header");
$this->load->view("site_navigation");
$this->load->view("content_Quiz");
}
public function Quizpage() {
$this->load->helper('url');
$this->load->view("site_header");
$this->load->view("site_navigation");
$this->load->view("content_quizpage");
}
public function Result() {
$this->load->helper('url');
$this->load->view("site_header");
$this->load->view("site_navigation");
$this->load->view("content_result");
}
}
routes.php文件:
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
查看:
<div id="container">
<h1>Quiz</h1>
<div id="content">
<?php
//Creating random number s
$rid = rand(1,3);
echo $rid;
?>
<?php
if ($rid == 1){
echo "
<form class="addinvestmentform" action="<?php echo base_url();?>index.php/Welcome/result" method='post' id='quizForm' id='1'/>
<input type="hidden" name="id" value="1"/>
<ol>
<li>
<h3>What does PHP stand for?</h3>
<div>
<input type='radio' name='answerOne' id='answerOne' value='A' />
<label for='answerOneA'>A) Hyper text markup language</label>
</div>
<div>
<input type='radio' name='answerOne' id='answerOne' value='B' />
<label for='answerOneB'>B) PHP: Preprocessed hypertext</label>
</div>
<div>
<input type='radio' name='answerOne' id='answerOne' value='C' />
<label for='answerOneC'>C) PHP: Hypertext Preprocessor</label>
</div>
</li>
答案 0 :(得分:0)
使用base_url()并将参数保存在隐藏文件中
<form class="addinvestmentform" action="<?php echo base_url();?>index.php/controller_name/function" method='post' id='quizForm' id='1'/>
<input type="hidden" name="id" value="1"/>
</form>
And change your view code to
<h1>Quiz</h1>
<?php
//Creating random number s
$rid = rand(1,3);
echo $rid;
?>
<?php
if ($rid == 1){
?>
<form class="addinvestmentform" action="<?php echo base_url();?>index.php/Welcome/result" method='post' id='quizForm' id='1'/>
<input type="hidden" name="id" value="1"/>
<ol>
<li>
<h3>What does PHP stand for?</h3>
<div>
<input type='radio' name='answerOne' id='answerOne' value='A' />
<label for='answerOneA'>A) Hyper text markup language</label>
</div>
<div>
<input type='radio' name='answerOne' id='answerOne' value='B' />
<label for='answerOneB'>B) PHP: Preprocessed hypertext</label>
</div>
<div>
<input type='radio' name='answerOne' id='answerOne' value='C' />
<label for='answerOneC'>C) PHP: Hypertext Preprocessor</label>
</div>
</li>
</form>
<?php } ?>