Okay, so I have created a website using php and codeigniter, also using nosql. All my pages are working except for one.
好的,所以我使用php和codeigniter创建了一个网站,也使用了nosql。我的所有页面都在工作,除了一个。
I have checked everything in the dashboard controller and it looks like it should work, yet every time i try and link to the page i get the 404 error and this also happens when i type in the url manually.
我检查了仪表板控制器中的所有内容,它看起来应该可以工作,但每次我尝试链接到页面时,我都会收到404错误,当我手动输入网址时也会发生这种情况。
Any ideas on what this could be?
关于这可能是什么的任何想法?
Here is what's in the dashboard
这是仪表板中的内容
public function Result() {
$this->load->helper('url');
$this->load->view("site_header");
$this->load->view("site_navigation");
$this->load->view("content_result");
}
And here is where it's being linked to from another page within a form
这里是从表单中的另一个页面链接到的地方
<form action='content_result.php?id=1' method='post' id='quizForm' id='1'>
Controller Code:
<?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;
View:
<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>
1 个解决方案
#1
Use base_url() and keep parameter in hidden file
使用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 } ?>
#1
Use base_url() and keep parameter in hidden file
使用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 } ?>