单击"登录"按钮转到"404 页面未找到"(CodeIgniter)



我正在尝试通过重定向或加载项目的另一个视图来检查我的登录按钮是否有效。但是,每次我单击按钮时,"找不到404页面" 未找到您请求的页面"

我很难弄清楚该怎么做。我花了将近 2 天的时间试图解决这个问题。我尝试了所有可能的解决方案。

我的控制器代码:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login_controller extends CI_Controller {
public function __construct() {
parent::__construct();
// Load form helper library
$this->load->helper('form');
$this->load->helper('url');
// // Load form validation library
// $this->load->library('form_validation');
// // Load session library
// $this->load->library('session');
// // Load database
// $this->load->model('login_database');
}
public function index()
{
$this->load->view('includes/Login/Login_Header'); //$data);     
$this->load->view('Login_view');
$this->load->view('includes/Login/Login_Footer');

}
public function login_submit()
{
$this->load->view('includes/SFM/SFM_Header'); //$data);
$this->load->view('includes/SFM/SFM_NavBar');
$this->load->view('SFM_view');
$this->load->view('includes/SFM/SFM_Footer');
}
}

我的登录视图代码:

<body>
<form class="login-form" action="<?=base_url()?>Login_controller/login_submit" method="post">
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100">
<form class="login100-form validate-form">
<span class="login100-form-title p-b-26">
Welcome
</span>
<span class="login100-form-title p-b-48">
<i class="zmdi zmdi-font"></i>
</span>
<div class="wrap-input100 validate-input" data-validate="Valid email is: a@b.c">
<input class="input100" type="text" name="Username">
<span class="focus-input100" data-placeholder="Email"></span>
</div>
<div class="wrap-input100 validate-input" data-validate="Enter password">
<span class="btn-show-pass">
<i class="zmdi zmdi-eye"></i>
</span>
<input class="input100" type="password" name="Password">
<span class="focus-input100" data-placeholder="Password"></span>
</div>
<div class="container-login100-form-btn">
<div class="wrap-login100-form-btn">
<div class="login100-form-bgbtn" ></div>
<button class="login100-form-btn">
Login
</button>
</div>
</div>
<div class="text-center p-t-115">
<span class="txt1">
Don’t have an account?
</span>
<a class="txt2" href="#">
Sign Up
</a>
</div>
</form>
</div>
</div>
</div>

<div id="dropDownSelect1"></div> 

索引时.php的这些错误不会在代码点火器中删除。 试试这个网址

  1. action="<?=base_url()?>Login_controller/index.php/login_submit"

如果您删除了索引.php,也请尝试此代码。

<form class="login-form" action="<?=base_url()?>Login_controller/login_submit" method="post">
<div class="wrap-input100 validate-input" data-validate="Valid email is: a@b.c">
<input class="input100" type="text" name="Username">
<span class="focus-input100" data-placeholder="Email"></span>
</div>
<div class="wrap-input100 validate-input" data-validate="Enter password">
<span class="btn-show-pass">
<i class="zmdi zmdi-eye"></i>
</span>
<input class="input100" type="password" name="Password">
<span class="focus-input100" data-placeholder="Password"></span>
</div>
<div class="container-login100-form-btn">
<div class="wrap-login100-form-btn">
<div class="login100-form-bgbtn" ></div>
<input type="submit" class="login100-form-btn" value="Login">
</div>
</div>
</form>

我认为您在提交表单时的 URL 存在问题。

如果您没有从 config.php 中删除 index.php 文件 ($config['index_page'] = 'index.php'; )

试试这个

<form class="login-form" action="<?php echo base_url()?>index.php/Login_controller/login_submit" method="post">

或者你可以试试这个

<form class="login-form" action="<?php echo base_url()?>Login_controller/login_submit" method="post">

而不是使用这个

<form class="login-form" action="<?=base_url()?>Login_controller/login_submit" method="post">

还要检查您的base_url是否正确

问题解决了!

问题是我的RewriteBase/FPOOPS全部大写。当我将其更改为/fpoops 时,它现在可以工作了!

Options -indexes
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /FPOOPS
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</ifModule>
<ifModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</ifModule>

相关内容

  • 没有找到相关文章