Codeigniter表单不会重定向到预期的URL

时间:2015-11-19 11:00:57

标签: html codeigniter-2 html-form

这是我的表格网址:

http://localhost/MCQQuizWebApp/index.php

这是表格:

<?php echo form_open('front_controller/show_result'); ?>
        <?php
            $ques_no = 1;
            foreach($questions as $question)
            {
                echo '<div class="section">';
                echo '<div class="question">';
                echo 'Q' . $ques_no . '. ' .$question->ques_desc;
                echo '</div>';
                foreach($choices[$question->ques_id] as $choice)
                {
                    echo '<div class="choice">';
                    echo $choice;
                    echo '</div>';
                }
                $ques_no++;
                echo '</div><br>';
            }
        ?>
        <input type="submit" value="Submit"/>
    <?php echo  form_close();?>

这是我的控制者:

class Front_controller extends CI_Controller{

    public function __construct()
    {
        parent::__construct();
                $this->load->helper('form');
    }

    public function index()
    {

    }

    public function show_result(){

    }

form_open(&#39; front_controller / show_result&#39);不会重定向到网址http://localhost/MCQQuizWebApp/index.php/front_controller/show_result

生成代码
form_open('front_controller/show_result');

<form action="http://::1/MCQQuizWebApp/index.php/front_controller" method="post" accept-charset="utf-8">

1 个答案:

答案 0 :(得分:1)

你可以尝试这个,只需在你的前面<form role="form" method="post" action="<?php echo site_url('front_controller/show_result');?>">

回应这个