Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在Codeigniter中重定向页面时出错_Php_Codeigniter - Fatal编程技术网

Php 在Codeigniter中重定向页面时出错

Php 在Codeigniter中重定向页面时出错,php,codeigniter,Php,Codeigniter,我想请求一些关于重定向页面的帮助..我想要的是在添加数据后,我希望我的页面直接指向某个页面,其中显示所有产品。。我期待的链接是 "http://localhost/CrudApp/index.php/GetProductController但我想说的是: "http://localhost/CrudApp/index.php/index.php/index.php/GetProductController'导致找不到404页。。请给我一些帮助。提前谢谢 这是我的密码: AddProduct.ph

我想请求一些关于重定向页面的帮助..我想要的是在添加数据后,我希望我的页面直接指向某个页面,其中显示所有产品。。我期待的链接是

"http://localhost/CrudApp/index.php/GetProductController但我想说的是:

"http://localhost/CrudApp/index.php/index.php/index.php/GetProductController'导致找不到404页。。请给我一些帮助。提前谢谢

这是我的密码:

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>

我还配置了我的config.php,我的baseurl是'index.php'

在CI上路由的正确方法是写入:

类/方法 所以在你的情况下,你必须写作

redirect('GetProductController/index');
另一个选项是在1个控制器上设置不同的功能,并通过以下方式访问这些功能: (当我们谈论相同的“产品”时)


为同一项目的每个不同操作创建控制器是没有逻辑意义的。

Svetlio是正确的。另外,如果你在谈论产品,你应该创建一个产品控制器,并在这个控制器内设置你的所有功能:添加、编辑、awesomefunction等等

所以你可以这样做:

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


如果重定向页面不是分隔符->重定向('GetProductController'),则在重定向页面上没有斜杠@斯维特利奥你好。我还尝试了“重定向('GetProductController');”但仍然是相同的结果,index.php被重新键入3次。请尝试此重定向('controllerName/function_name');在SaveProductController中是否有函数GetProductController?如果是新的控制器,则必须重定向为:redirect('GetProductController/index');然后我应该将我的saveproduct、addproduct和其他任务(如编辑和删除)放在一个控制器中?也许这就是为什么我不能重定向我的页面,在我的url中,index.php被键入了3次。。。
Product/set
Product/get
redirect(site_url('products/where_you_want_go_function'));
redirect('products/where_you_want_go_function');