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条)

报告相同问题?

悬赏问题

  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 python进程启动打包问题
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题