douhuo1738 2015-05-05 08:17
浏览 25

仅在一个页面上的Codeigniter 404错误

Okay, so I have created a website using php and codeigniter, also using nosql. All my pages are working except for one.

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.

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条回答 默认 最新

  • dongnuoyi8833 2015-05-05 08:43
    关注

    Use base_url() and keep parameter in hidden file

        <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 } ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000