Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 404找不到页面找不到您请求的页面。视频教程_Php_Codeigniter - Fatal编程技术网

Php 404找不到页面找不到您请求的页面。视频教程

Php 404找不到页面找不到您请求的页面。视频教程,php,codeigniter,Php,Codeigniter,嗨,我是codeigniter的新手。我有一个代码,这是正常工作前几天,但当我再次打开它是给我的错误页面,你要求没有找到。基本上,代码是关于在数据库中添加用户的。请帮帮我,我需要你的建议。这是我的模型、控制器和视图代码 模型文件 Userinsert\u model.php <?php class Userinsert_model extends CI_Model{ function __construct() { parent::__construct(); } function for

嗨,我是codeigniter的新手。我有一个代码,这是正常工作前几天,但当我再次打开它是给我的错误页面,你要求没有找到。基本上,代码是关于在数据库中添加用户的。请帮帮我,我需要你的建议。这是我的模型、控制器和视图代码

模型文件

Userinsert\u 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();

}

}



?>
<?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);  
}
}



?>
<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>

控制器文件

Userinsert\u controller.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();

}

}



?>
<?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);  
}
}



?>
<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>

重命名
类用户插入\u控制器扩展CI\u控制器{
类用户插入扩展CI\U控制器{

然后通过example.com/index.php/userinsert访问该站点

您的
应用程序/config/routes.php
必须如下所示

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

/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
|   example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
|   https://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are three reserved routes:
|
|   $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
|   $route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router which controller/method to use if those
| provided in the URL cannot be matched to a valid route.
|
|   $route['translate_uri_dashes'] = FALSE;
|
| This is not exactly a route, but allows you to automatically route
| controller and method names that contain dashes. '-' isn't a valid
| class or method name character, so it requires translation.
| When you set this option to TRUE, it will replace ALL dashes in the
| controller and method URI segments.
|
| Examples: my-controller/index -> my_controller/index
|       my-controller/my-method -> my_controller/my_method
*/
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

/* CUSTOM ROUTES */
$route['userinsert'] = 'Userinsert';

config.php中
replace

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

$config['index_page'] = '';


您能展示一下config/routes.php的样子吗?404错误可能是由于routes中的错误配置造成的you@Kuru$route['default\u controller']='welcome';$route['404\u override']='';$route['translate\u uri\u破折号']=FALSE;@dawoodbasharat我非常感谢阅读这篇将Userinsert\u controller.php重命名为Userinsert\u controller.phpSir仍然是相同的问题
应用程序/controller
中的控制器是吗?是的,这就是为什么我将其命名为Userinsert\u controller只是为了便于记忆。但是我更改了UserinsertCan的名称,你可以给我们一个屏幕截图fr从您的文件夹结构?很抱歉,我没有得到它!!我需要向您发送我的文件在哪些文件夹中的屏幕截图,还是需要给您配置文件的屏幕截图?让我再次检查一下,除了这一行/*自定义路由*/$route['userinsert']='Userinsert';您如何访问该网站?使用哪个url?以下是它使用的url您建议我使用的url,但问题是remainsHappy编码(Y)我可以向你寻求更多的帮助吗?当然可以。如果你想修复一些错误,你可以提出新问题。@我有一些新问题,它与会话有关!如果你不介意,我可以通过你的电子邮件或其他类似的东西与你联系吗?如果你觉得不方便,请不要介意