Codeigniter项目显示404错误或空白页面

时间:2014-02-06 07:32:54

标签: php codeigniter

Codeigniter中的我的项目未运行。我无法解决它面临的问题。我已正确设置数据库。在路由中,我为控制器设置了路径。

Controller - groups_controller

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

class Groups_controller extends CI_Controller
{

    function index()
    {
        $this->load->view('groups');
    }

    public function group()
    {

    $this->load->model('groups_model');
        if(isset($_POST['addgroup']))
        {
            $userID=  '2';
            $groupname=  $this->input->post('group');
            $data=array(
                'userID'=>$userID,
                'groupname'=>$groupname
            );
            $this->groups_model->insert_groups($data);
            //var_dump($this->db->last_query());
        }

    }
}
?>

模型 - groups_model.php

function insert_groups($dbdata) {
        $this->db->insert('groups', $dbdata);
        $this->db->last_query();
    }

查看 - groups.php

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>Content</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <!-- Bootstrap -->
        <link href="<?php echo base_url(); ?>stylesheets/bootstrap.min.css" rel="stylesheet" type="text/css">
        <link href="<?php echo base_url(); ?>stylesheets/bootstrap.css" rel="stylesheet" type="text/css">
        <link href="<?php echo base_url(); ?>stylesheets/bootstrap-theme.min.css" rel="stylesheet" type="text/css">
        <link href="<?php echo base_url(); ?>stylesheets/bootstrap-theme.css" rel="stylesheet" type="text/css">
        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
        <SCRIPT language="javascript">

//            var person;
//            var element;
//
//            function add() {
//                var e1 = document.getElementById('group').value;
//                var e2 = document.getElementById('select');
//                var o = document.createElement('option');
//                o.value = "group_body.html";
//                o.text = e1;
//                e2.options.add(o);
//
//            }

//            function goto() {
//                var index = document.getElementById('select').selectedIndex;
//                if (index.value != "select") {
//                    location = index.value;
//                }
//            }
//            function add()
//            {
//                //Create an input type dynamically.   
//                element = document.createElement("button");
//                element.className='btn btn-default';
//                var person = document.getElementById('group').value;
//                var t = document.createTextNode(person);
//                element.appendChild(t);
//                element.id=person;
//                //Assign different attributes to the element. 
////                    element.type = type;
////                    element.value = type; // Really? You want the default value to be the type string?
////                    element.name = type;  // And the name too?
//                
//                element.onclick = function() { // Note this is a function
//                  //alert(element.id);
////                   $(document).ready(function(){
////                 $("#element").click(function(){
//                     $('body').load('group_body.html');
////                 });
////            });
//                };
//
//                var foo = document.getElementById("fooBar");
//                //Append the element in page (in span).  
//                foo.appendChild(element);
////                    var d = document.getElementById('fooBar');
////                    d.appendChild(i);
//            }
//
//            function copy()
//            {
//                var n1 = document.getElementById('addKeyword');
//                var n2 = document.getElementById('getKeyword');
//                n2.innerText = n1.value;
//            }

        </SCRIPT>
    </head>
    <body>
        <form method="post" name="form1">
        <div class="btn-group" id="fooBar">
            <!--            <button type="button" class="btn btn-default">Marketing</button>
                        <button type="button" class="btn btn-default">Internet</button>
                        <button type="button" class="btn btn-default">Politics</button>-->

            select a group:
            <select class="form-control" id="select" onchange="javascript:location.href = this.value;">
                <option selected value="select">select</option>
                <!--                <option>2</option>
                                <option>3</option>
                                <option>4</option>
                                <option>5</option>-->
            </select>
            <button type="button" class="btn btn-default" id="btnAdd" data-toggle="modal" data-target="#myModal">Add Group</button>
        </div>
        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">Group Name</h4>
                    </div>
                    <div class="modal-body">
                        <h5>Please enter Group Name:</h5>
                        <input type="text" name="group" id="group" placeholder="Group"> 
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                        <button type="submit" name="addgroup" class="btn btn-primary" id="add"  data-dismiss="modal">Add</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
        <div class="boxed">
            <h4>Group:<span class="label label-default" id="span"><script>document.getElementById('group').innerText = document.getElementById('span').innerText</script></span>
                <button type="submit" class="btn btn-default">Edit Name</button>
                <button type="submit" class="btn btn-default">Disable</button>
                <button type="submit" class="btn btn-default">Delete Group</button></h4>
            <div class="row">
                <div class="col-lg-6">
                    <div class="input-group">
                        <input type="text" class="form-control" placeholder="Enter your keyword" id="addKeyword">
                        <span class="input-group-btn">
                            <button class="btn btn-default" type="button" onclick="copy()">Add</button>
                        </span>
                    </div><!-- /input-group -->
                </div><!-- /.col-lg-6 -->
            </div>
            <h4>Keywords:</h4>
            <!--            <div class="keyword" id="getKeyword"></div>-->
        </div>
        </form>

        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
        <script src="https://code.jquery.com/jquery.js"></script>
        <!-- Include all compiled plugins (below), or include individual files as needed -->
        <script src="<?php echo base_url(); ?>javascripts/bootstrap.min.js"></script>
        <script src="<?php echo base_url(); ?>javascripts/bootstrap.js"></script>
    </body>
</html>

0 个答案:

没有答案