简体   繁体   English

是否可以将URL中的ID的segment(3)更改为随机字符串(Codeigniter)?

[英]Is it possible to change the segment(3) which is the ID in my url into a random string(Codeigniter)?

I tried to change the $config['url_suffix'](that is located at my config/config) into $config['url_suffix'] = ''; 我试图将$ config ['url_suffix'](位于我的config / config中)更改为$ config ['url_suffix'] =''; . I encountered an error, it says that "Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server. 我遇到一个错误,它说“禁止访问!您无权访问所请求的对象。它是受读保护的,或者服务器不可读。

If you think this is a server error, please contact the webmaster." And I also tried to put the random_string in my view, may update is not working now 如果您认为这是服务器错误,请与网站管理员联系。”我也尝试将random_string放入我的视图,现在更新可能无法正常工作

Config file 配置文件

$config['url_suffix'] = '<?= random_string(40?>';

View 视图

<a data-toggle="modal" class="btn btn-warning" data-target="#update_account-<?= $profileAccount->id?>"><span class="glyphicon glyphicon-edit"></span>Edit</a>
    <div class="modal fade" id="update_account-<?= $profileAccount->id?>" tabindex="-1" role="dialog" aria-labelledby="titleLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header modal-header-success">
                    <button type="button" class="close btn btn-primary" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="titleLabel">Update Profile</h4>
                    </div>
                    <div class="modal-body">
                      <div class="container">
                        <div clas="row">
                            <form method="post" action="<?= base_url(). 'User/updateProfile/'.random_string($profileAccount->id)?>"> 
                                <div class="col-md-5 col-lg-5">
                                   <?= validation_errors();?>
                                   <div class="form-group">
                                    <label>ID</label>
                                    <input type="text" disabled value="<?= $profileAccount->id?>" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>First Name</label>
                                    <input type="text" name ="fname"value="<?= $profileAccount->first_name?>" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>Middle Name</label>
                                    <input type="text" name ="mname" value="<?= $profileAccount->middle_name?>" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>Last Name</label>
                                    <input type="text" name ="lname" value="<?= $profileAccount->last_name?>" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>Email Address</label>
                                    <input type="email" name ="email" value="<?= $profileAccount->email?>" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>Password</label>
                                    <input type="password" name ="password" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>Contact Number</label>
                                    <input type="text" name ="phone" value="<?= $profileAccount->phone?>" class="form-control">
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <span class="pull-right">
                       <button type="submit" class="btn btn-success">Update Event</button>
                       <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                   </span>
               </form>
           </div>
       </div>
   </div>
</div> 

Your config has missing character the closing parenthesis ) 您的配置缺少右圆括号

change this 改变这个

$config['url_suffix'] = '<?= random_string(40?>';

to

$config['url_suffix'] = '<?= random_string(40)?>';

If not working I think your random_string function has an error 如果不起作用,我认为您的random_string函数有错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM