douzhe9075 2016-08-21 16:08
浏览 12

当我从codeigniter中的另一个视图调用视图时,找不到页面

I am trying to submit my form using post method in codingniter , and my form is called from the main view when i submit the form i get 404 Page is not found .

This is my header form :

<form class="form-horizontal" id="sendform" role="form" action="<?php echo `base_url('/pages/insert_into_db') ;?>" method="post" >`

and in the controller i have this function controller :

pages.php :

        <?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Pages extends CI_Controller {
public function view ($page='gurantee'){
    if ( ! file_exists(APPPATH.'views/pages/'.$page.'.php'))
        {
                // Whoops, we don't have a page for that!
                show_404();
        }
        $this->load->view('pages/'.$page);
      }  

    public function index ()
    {
        $this->load->helper('url');
        $this->load->view('Welome');
    }
     public function display () {

         $this->load->model('ektreemodel');
         $data['query']=$this->ektreemodel->display();
         $this->load->view('table',$data);
    }
      public function insert_to_db()
      {
        $this->load->helper('url');
        $this->load->model('ektreemodel');
        $this->ektreemodel->insert_into_db();
        $this->load->view('gurantee');
    }

    public function dis () {
       $this->load->helper('url');
        $this->load->view('registration');
      }

}

and the url is :

http://localhost:8888/index.php/pages/index.php/pages/display

it was working fine when i submit my form the main first view , is there something i have to change or , is there some way i can use javascript , so when i will use post method it will call display function from the controller ?

  • 写回答

3条回答 默认 最新

  • doujiao7679 2016-08-21 16:12
    关注

    Solution 1

    <form class="form-horizontal" id="sendform" role="form" action="<?php echo site_url('pages/display') ;?>" method="post" >`
    

    Use this code that has site_url() rather than base_url()

    Solution 2

    If that doesn't work a more logical way would be:

    echo form_open('pages/display', 'class="form-horizontal" id="sendform"');
    

    This would generate the form tag for you. Hope this helps :)

    Solution #3:

    Make "p" capital in pages.php making it Pages.php

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用