【问题标题】:PHP Submit button not responding (Codeigniter)PHP提交按钮没有响应(Codeigniter)
【发布时间】:2014-03-05 04:30:47
【问题描述】:

我有以下视图(home_view.php)

<?php $this->load->helper('url'); 


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>diluks eCommerce - Home</title>
      <link href="<?php echo base_url();?>Public/scripts/style.css" rel="stylesheet" type="text/css" />
   </head>
   <body>
   <form action="<?php echo base_url();?>index.php/welcome_controller" method="post">
      <div class="container">
          <?php 
$userpermission = $this->session->userdata('userpermission');

if($userpermission==1){
   include 'header-admin.php'; 
}
else if($userpermission==2){
   include 'header-user.php'; 
}
else{
include 'header-guest.php';}

 ?>
         <div class="level3 clearfix">
            <?php include 'shopping-sidebar.php'; ?>
            <div class="body-content">

               <div class="image-slider">
                  <img src="<?php echo base_url();?>Public/img/main-img.png" width="785" height="220" />
               </div>
               <div class="seperate-space">
                  <div class="separate-title"><a class="bold-captions">Latest Picks</a>
                  </div>
               </div>
               <div class="items">
                  <div class="item-holder">
                     <table align="center" width="256px" cellpadding="0px" cellspacing="0px">
                        <tr>
                           <td class="item-info" align="center" height="34px">Item name</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="230px">
                              <img src="<?php echo base_url();?>Public/img/sunflowers.png" width="256" height="230" />
                           </td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="34px">$30</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
                        </tr>
                     </table>
                  </div>
                  <div class="item-holder">
                     <table align="center" width="256px" cellpadding="0px" cellspacing="0px">
                        <tr>
                           <td class="item-info" align="center" height="34px">Item name</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="230px">
                              <img src="<?php echo base_url();?>Public/img/treecard.png" width="256" height="230" />
                           </td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="34px">$30</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
                        </tr>
                     </table>
                  </div>
                  <div class="item-holder">
                     <table align="center" width="256px" cellpadding="0px" cellspacing="0px">
                        <tr>
                           <td class="item-info" align="center" height="34px">Item name</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="230px">
                              <img src="<?php echo base_url();?>Public/img/3-flowers.png" width="256" height="230" />
                           </td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="34px">$30</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
                        </tr>
                     </table>
                  </div>
                  <div class="item-holder">
                     <table align="center" width="256px" cellpadding="0px" cellspacing="0px">
                        <tr>
                           <td class="item-info" align="center" height="34px">Item name</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="230px">
                              <img src="<?php echo base_url();?>Public/img/sunflowers.png" width="256" height="230" />
                           </td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="34px">$30</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
                        </tr>
                     </table>
                  </div>
                  <div class="item-holder">
                     <table align="center" width="256px" cellpadding="0px" cellspacing="0px">
                        <tr>
                           <td class="item-info" align="center" height="34px">Item name</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="230px">
                              <img src="<?php echo base_url();?>Public/img/treecard.png" width="256" height="230" />
                           </td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="34px">$30</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
                        </tr>
                     </table>
                  </div>
                  <div class="item-holder">
                     <table align="center" width="256px" cellpadding="0px" cellspacing="0px">
                        <tr>
                           <td class="item-info" align="center" height="34px">Item name</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="230px">
                              <img src="<?php echo base_url();?>Public/img/3-flowers.png" width="256" height="230" />
                           </td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="34px">$30</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
                        </tr>
                     </table>
                  </div>
                  <div class="item-holder">
                     <table align="center" width="256px" cellpadding="0px" cellspacing="0px">
                        <tr>
                           <td class="item-info" align="center" height="34px">Item name</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="230px">
                              <img src="<?php echo base_url();?>Public/img/sunflowers.png" width="256" height="230" />
                           </td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="34px">$30</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
                        </tr>
                     </table>
                  </div>
                  <div class="item-holder">
                     <table align="center" width="256px" cellpadding="0px" cellspacing="0px">
                        <tr>
                           <td class="item-info" align="center" height="34px">Item name</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="230px">
                              <img src="<?php echo base_url();?>Public/img/treecard.png" width="256" height="230" />
                           </td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="34px">$30</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
                        </tr>
                     </table>
                  </div>
                  <div class="item-holder">
                     <table align="center" width="256px" cellpadding="0px" cellspacing="0px">
                        <tr>
                           <td class="item-info" align="center" height="34px">Item name</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="230px">
                              <img src="<?php echo base_url();?>Public/img/3-flowers.png" width="256" height="230" />
                           </td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="34px">$30</td>
                        </tr>
                        <tr>
                           <td class="item-info" align="center" height="35px"><input name="btn_read" class="readbtn" value="Read More" /></td>
                        </tr>
                     </table>
                  </div>
               </div>
            </div>
         </div>
         <div style="clear:both"></div>
         <div class="level4">
            <div class="footer-area">
               <div class="lined-space"></div>
               <div class="site-map" align="left">
                  <table>
                     <tr>
                        <td class="footer-text"><a href="#">About Us</a></td>
                        <td class="footer-text"><a href="#">Facebook</a></td>
                     </tr>
                     <tr>
                        <td class="footer-text"><a href="#">Contact Us</a></td>
                        <td class="footer-text"><a href="#">Twitter</a></td>
                     </tr>
                     <tr>
                        <td class="footer-text"><a href="#">FAQs</a></td>
                        <td class="footer-text"><a href="#">Terms & Conditions</a></td>
                     </tr>
                     <tr>
                        <td class="footer-text"><a href="#">Help</a></td>
                     </tr>
                  </table>
               </div>
               <div class="developer-info">
                  <a class="developers-text">Designed & Developed By Diluks Software Solutions.</a>
               </div>
            </div>
         </div>
      </div>
      </form>
   </body>
</html>

该控制器(welcome_controller)如下,

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome_controller extends CI_Controller {

function __construct(){
        parent::__construct();


    }

    public function index()
    {
        if(isset($_POST["btn_login"])){
          $data = array();
            $this->load->model('category_model');
            $data['categories'] = $this->category_model->getCategories();

          $this->load->view('login_view', $data);
        }
        else if(isset($_POST["btn_adminpanel"])){

          $this->load->view('adminpanel_view');
        }
        else if(isset($_POST["btn_logout"])){

          $this->session->sess_destroy();
          $data = array();
            $this->load->model('category_model');
            $data['categories'] = $this->category_model->getCategories();
            $this->load->view('home_view', $data);
        }
        else if(isset($_POST["btn_read"])){

            $this->load->view('readmore_view');

        }

    }


}

现在我需要将页面重定向到 readmore_view onClick 名为“btn_read”的按钮,但它没有响应。 (注意:有 9 个按钮具有相同的名称,我已经测试了更改其中一个并在控制器中给出特定名称,它也不起作用。)请给我一个解决方案。

【问题讨论】:

    标签: php forms codeigniter


    【解决方案1】:

    &lt;input name="btn_read" class="readbtn" value="Read More" /&gt; 没有输入类型。您必须提及输入的类型。

    <input type="submit" name="btn_read" class="readbtn" value="Read More" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-13
      • 2021-12-15
      • 2018-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多