php - 404 Page Not Found 没有找到您请求的页面。代码点火器

标签 php codeigniter

enter image description here

您好,我是 codeigniter 的新手。我有一个几天前工作正常的代码,但是当我再次打开它时,它给了我找不到你请求的页面的错误。基本上代码是关于在数据库中添加用户。请在这里帮助我,我需要你的建议。这是我的模型、 Controller 和 View 代码。

模型文件

Userinsert_model.php

<?php
class Userinsert_model extends CI_Model{
function __construct() {
parent::__construct();
}
function form_insert($data){

$this->db->insert('students', $data);
}

public function datafetch(){
    $fetch= $this->db->get('students'); 
    return $fetch->result();

}

}



?>

Controller 文件

Userinsert_controller.php

<?php

class Userinsert_controller extends CI_Controller {

function __construct() {
parent::__construct();
$this->load->model('Userinsert_model');
}
function index() {

$this->load->library('form_validation');

$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

$this->form_validation->set_rules('dname', 'Username', 'required|min_length[5]|max_length[15]');

$this->form_validation->set_rules('demail', 'Email', 'required|valid_email');

$this->form_validation->set_rules('dmobile', 'Mobile No.', 'required|regex_match[/^[0-9]{10}$/]');

$this->form_validation->set_rules('daddress', 'Address', 'required|min_length[10]|max_length[50]');

if ($this->form_validation->run() == FALSE) {
$this->load->view('Userinsert_view');
} else {
$data = array(
'Student_Name' => $this->input->post('dname'),
'Student_Email' => $this->input->post('demail'),
'Student_Mobile' => $this->input->post('dmobile'),
'Student_Address' => $this->input->post('daddress')
);
$this->Userinsert_model->form_insert($data);
$data['message'] = 'Data Inserted Successfully';
$this->load->view('Userinsert_view', $data);
}
}
public function fetch() {

    $this->load->model('Userinsert_model');

        $data["all_data"]= $this->Userinsert_model->datafetch();
$this->load->helper('form');
    $this->load->view('Usershow_view', $data);  
}
}



?>

查看文件

Userinsert_view.php

<html>
<head>
<title>Insert Data Into Database Using CodeIgniter Form</title>
</head>
<body>

<div id="container">
<?php echo form_open('Userinsert_controller'); ?>

<h1>Insert Data Into Database Using CodeIgniter</h1><hr/>
<?php if (isset($message)) { ?>
<CENTER><h3 style="color:green;">Data inserted successfully</h3></CENTER><br>
<?php } ?>
<?php echo form_label('Student Name :'); ?> <?php echo form_error('dname'); ?><br />
<?php echo form_input(array('id' => 'dname', 'name' => 'dname')); ?><br />

<?php echo form_label('Student Email :'); ?> <?php echo form_error('demail'); ?><br />
<?php echo form_input(array('id' => 'demail', 'name' => 'demail')); ?><br />

<?php echo form_label('Student Mobile No. :'); ?> <?php echo form_error('dmobile'); ?><br />
<?php echo form_input(array('id' => 'dmobile', 'name' => 'dmobile', 'placeholder' => '10 Digit Mobile No.')); ?><br />

<?php echo form_label('Student Address :'); ?> <?php echo form_error('daddress'); ?><br />
<?php echo form_input(array('id' => 'daddress', 'name' => 'daddress')); ?><br />

<?php echo form_submit(array('id' => 'submit', 'value' => 'Submit')); ?>
<?php echo form_close(); ?><br/>
<div id="fugo">

</div>
</div>
</body>
</html>

最佳答案

在你的 config.php 中替换

$config['index_page'] = 'index.php';  

$config['index_page'] = '';

关于php - 404 Page Not Found 没有找到您请求的页面。代码点火器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43972879/

相关文章:

php - 您如何自定义/设置 codeigniter 错误的样式?

php - SQL Select 和 UPDATE 有多列且应选择一行

javascript - 如何使用AngularJS的多个ajax调用($http)从单个php文件请求数据?

php - 用户输入值 sql 的日期之间

php - Codeigniter 更新函数中的两个不同的表名

php - codeigniter 中的表单助手自动转义表单数据?

php - 安全 Codeigniter 应用程序无法连接到 MySQL 数据库?

php - Codeigniter Profiler 不显示 INSERT 和 UPDATE 查询

php - 什么是通过 rss 提要将 html 嵌入代码传递给 php 中的 rss 解析器的最佳方法?

PHP MySQL 大量查询被传递,