doutizha7526 2013-12-14 09:25
浏览 60
已采纳

Codeigniter按钮重定向

I just want to ask because I'm working on Codeigniter and I'm have a button in home page wherein if click, it will page redirect to registration page.

<input type='button' onClick='<?php redirect(base_url() . 'register/index'); ?>' />

I also tried the form helper.

<body>
    <?php
        $data = array('register' => array('name'    => 'register',
            'id'        => 'register',
            'value' => 'TRUE',
            'type'  => 'button',
            'content' => 'Register',
            'onClick'   => redirect(base_url() . 'register/index')
       );
    ?>
<table border="1">
    <tr>
        <td><?php echo form_button(element('register', $data, )); ?></td>
        <td></td>
    </tr>

</table>
</body>

The problem is nothing happens when I try to click the button.

  • 写回答

3条回答 默认 最新

  • duanlang1531 2013-12-14 09:27
    关注

    CodeIgniter's redirect() function means to make a HTTP 302 response, which only works before content being outputted. It's designed for controller and should never appear in your views.

    Navigation in browser-side can be implemented by Javascript:

    <button onclick="location.href='<?php echo base_url();?>register/index'">Register</button>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 我这模型写的不对吗?为什么lingo解出来的下面影子价格这一溜少一个变量
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波