duanlingzei0170 2012-12-27 14:57
浏览 47
已采纳

在Codeigniter中重定向页面时出错

I'd like to ask some help about redirecting a page..What I want is after I add a data I want my page to be direct to a certain page where all products where displayed.. The link I'm expecting is

'http://localhost/CrudApp/index.php/GetProductController' , but what I'm getting at is this:

'http://localhost/CrudApp/index.php/index.php/index.php/GetProductController' resulting a 404 Page not found.. please, some help. Thanks in advance..

here is my code:

AddProduct.php

    <form method="POST" action="SaveProductController"></br></br></br>
        <table border='1' align='center'>
            <tr>
                <td>ID: </td><td><input type="text" name="id" 
                                        value="<?php echo $GetProductId->id + 1; ?>" readonly="readonly"></td>
            </tr>
            <tr>
                <td>Description: </td><td><input type="text" name="description"></td>
            </tr>
            <tr>
                <td>Price: </td><td><input type="text" name="price"></td>
            </tr>
            <tr>
                <td>Size: </td><td><input type="text" name="size"><td>
            </tr>
            <tr>
                <td>Aisle: </td><td><select name="aisle">
                        <?php
                        foreach ($GetAisle as $row) {
                            printf("<option value='" . $row['id'] . "'>" . $row['description'] . "</option>");
                        }
                        ?>
                    </select></td>
            </tr>
            <tr>
                <td></td><td><input type="submit" name="addProduct" value="Add Product"><td>
            </tr>
        </table>
    </form>

and my controller: SaveProductController.php

function index() {
    $this->load->model('ProductDao');
    $id = $this->input->post('id');
    $description = $this->input->post('description');
    $price = $this->input->post('price');
    $size = $this->input->post('size');
    $aisle = $this->input->post('aisle');
    //$this->ProductDao->saveProduct($id, $description, $price, $size, $aisle);
    redirect('/GetProductController');
}

i also configure my config.php, my baseurl is 'index.php'

  • 写回答

2条回答 默认 最新

  • dongyu6276 2012-12-27 15:53
    关注

    Svetlio is right. Also if you are talking about product you shoul create a product Controller and inside this controller you set all your functions: add, edit, awesomefunction, whatever...

    So you can do it like:

    redirect(site_url('products/where_you_want_go_function'));
    

    or

    redirect('products/where_you_want_go_function');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)