doulai8128 2016-09-30 05:53
浏览 13
已采纳

(重新安排)笨。 我在哪里/如何编写登录方法,如果它在侧边栏上

beginner question sorry: I have template(just build it from scratch so it's a simple template by html css) that have header, navbar, content, sidebar, footer. but my loginbox is on the sidebar and my view files 'footer.php' consist of sidebar and footer. (so my loginbox is on footer.php) My controller, each method will import the header.php view, somemodule.php(content) view and footer.php view.

the problem is when I write the login method, it does not have content view because loginbox is in footer already. no nescessary for somemodule.php(content)view. (my login form post data to controller login method)

this is my controller

 public function login()
{
    $this->load->view('header');

    /// login and validation  algorithm here////
    /// not have $this->load->view('some content') ///

    $this->load->view('footer');  ////my loginform is in footer

}
 public function register()
{
   $this->load->view('header');
   $this->load->view('register_content');   // See? the other methods have a content view
   //// algorithm and validation here /////
   $this->load->view('footer');
}

this is my form in the footer view

<?php echo form_open('member/login');?>  //post data to method login controller
                    <h2> Login </h2>
                    <ul id='login'>
                        <li>
                            Username:<br>
                            <input type='text' name='username'>
                        </li>
                        <li>
                            Password:<br>
                            <input type='password' name='password'>
                        </li>
                        <br>
                        <li>
                            <input type='submit' name='btn' value='Log in'>
                        </li>
                    </ul>   
                </form>

When the user input wrong password, I want the website to be on same page with error message and the "content view" still be the same.

or should I write algorithm in Model folder and import it to controller? but it must import that login model to all method of controller because all page have footer(loginbox).

  • 写回答

1条回答 默认 最新

  • doujiongqin0687 2016-09-30 10:08
    关注

    Use ajax, do post request using ajax and in login method send response in json format and process it.

        `if ($this->input->server('REQUEST_METHOD') === 'POST') {
        // Validate Login
             return "{'status':'fail','msg':'invalid ID/Password'}";
        }`
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle触发器记录修改前后的字段值
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器