【问题标题】:How to link page with button click in Codeigniter?如何在 Codeigniter 中通过按钮单击链接页面?
【发布时间】:2016-03-30 08:16:49
【问题描述】:

我正在尝试在点击时加载页面, 我创建了一个电子邮件验证链接,它可以打开页面并更新我的数据库,一切正常,但该页面包含一个按钮,我希望用户单击该按钮并打开具有登录窗口的第一页。 我的 verify.html:

    <div class="container container-table">
    <div class="row vertical-center-row">
        <div class="text-center col-md-4 col-md-offset-4" style="background:blue">
            <h3> Thankyou For Veryfing</h3>    
            <p>You Are Verified</p>
            <form action="login.php/verify_to_login" method="post">
                <button type="submit" class="btn btn-success" >Sign Up>Go To Login</button> 
            </form>        
        </div>
    </div>
</div>  

我的控制器函数会像这样加载验证页面:http://localhost/index.php/login/verify/1567af19e10ce4

        public function verify($VerificationCode){
         $this->load->model('My_model');
         $this->load->helper('url');
         $this->My_model->verifymail($VerificationCode);
         /* Send to the verification page */
         $this->load->view("verify.html");
    }

这是我想要的 verify_to_login() 函数,当我单击按钮时它应该打开 header.html,这应该像 http://localhost/index.php/login/verify_to_login 但是当我点击按钮时,它显示http://localhost/index.php/login/verify/login.php/verify_to_login 公共功能 verify_to_login(){ $this->load->view("header.html"); }

我无法理解为什么会这样。?? :(

【问题讨论】:

    标签: php html codeigniter


    【解决方案1】:

    在 html 上

    <form method="" action="<?php  echo base_url(); ?>​controller_name/function_name">
           <button id="submit-buttons" type="submit" ​​​​​>Submit 1</button>
    </form>
    

    在控制器上

    function functionname(){
        $this->load->view('some_view')
    }
    

    所以基本上你的控制器没问题,所以只需通过输入控制器名称和函数名称来修复按钮,一切都应该可以正常工作。

    【讨论】:

      【解决方案2】:

      试试

      这个

      <button type="submit" class="btn btn-success" onclick="window.location.replace('YOUR_LINK_HERE');">Sign Up>Go To Login</button>
      

      <button type="submit" class="btn btn-success" onclick="window.location.href('YOUR_LINK_HERE');">Sign Up>Go To Login</button>
      

      【讨论】:

        猜你喜欢
        • 2011-05-05
        • 1970-01-01
        • 2013-01-10
        • 1970-01-01
        • 1970-01-01
        • 2014-01-11
        • 1970-01-01
        • 1970-01-01
        • 2016-03-07
        相关资源
        最近更新 更多