Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.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 与用户名和密码匹配时出现Codeigniter登录系统错误_Php_Html_Codeigniter - Fatal编程技术网

Php 与用户名和密码匹配时出现Codeigniter登录系统错误

Php 与用户名和密码匹配时出现Codeigniter登录系统错误,php,html,codeigniter,Php,Html,Codeigniter,我用codeigniter做了一个登录程序,当我在表单中输入错误的用户名或密码时没有问题,它会像在程序中一样向我发出失败警报。起初,我认为访问数据库没有问题。当我输入已经添加到数据库中的用户名和密码时,失败警报并没有像应该的那样出现。但当我在if-else程序中输入代码时。失败时显示警报,然后死亡(“成功”);如果它与密码和用户名匹配。但是die(success)代码不起作用,当我重定向到其他页面时,它也不能工作。如果variabel为FALSE,程序就可以工作 这是我的看法 <?php

我用codeigniter做了一个登录程序,当我在表单中输入错误的用户名或密码时没有问题,它会像在程序中一样向我发出失败警报。起初,我认为访问数据库没有问题。当我输入已经添加到数据库中的用户名和密码时,失败警报并没有像应该的那样出现。但当我在if-else程序中输入代码时。失败时显示警报,然后死亡(“成功”);如果它与密码和用户名匹配。但是die(success)代码不起作用,当我重定向到其他页面时,它也不能工作。如果variabel为FALSE,程序就可以工作

这是我的看法

<?php echo form_open('users/login'); ?>
<div class="row justify-content-md-center" ">

    <div class="col-md-4 col-md-4-offset-4 rounded-lg" style="background-color: white" > 
        <br>
        <h2 class="text-center"><?= $title ?></h2>
        <div class="form-group">
            <input type="text" name="username" class="form-control" placeholder="Masukkan Username" required autofocus>
        </div>
        <div class="form-group">
            <input type="password" name="password" class="form-control" placeholder="Masukkan Password" required autofocus>
        </div>
        <center><button type="submit" class="btn btn-success btn-block">LOGIN</button></center>
        <br>
    </div>


</div>


如果
方法
是默认的
GET
,则
表单验证
将不起作用。另外,
$this->input->post()
如果表单方法不是
post
,则不会给出任何结果,因此需要给出属性
method='post'

<?php 
   echo form_open('users/login', array('method'=>"POST"));
?>


如果您想使用
GET
方法验证表单,您需要查看并确认<看看它是否对你有帮助

如果
方法
是默认的
GET
,则
表单验证
将不起作用。另外,
$this->input->post()
如果表单方法不是
post
,则不会给出任何结果,因此需要给出属性
method='post'

<?php 
   echo form_open('users/login', array('method'=>"POST"));
?>
if($user_id == FALSE){
                die('success');
                $this->session->set_flashdata('login_failed','Login Gagal!');
                redirect('users/login');

如果您想使用
GET
方法验证表单,您需要查看并确认<看看它是否对你有帮助

if($user_id == FALSE){
                die('success');
                $this->session->set_flashdata('login_failed','Login Gagal!');
                redirect('users/login');
应该是

if($user_id){
                die('success');
                $this->session->set_flashdata('login_failed','Login Gagal!');
                redirect('users/login');
在这里,我们试图检查$user\u id是否返回true,如果它返回false,则调用其他块。无需将$user\u id与false进行比较($user\u id==false)

应该是

if($user_id){
                die('success');
                $this->session->set_flashdata('login_failed','Login Gagal!');
                redirect('users/login');
在这里,我们试图检查$user\u id是否返回true,如果它返回false,则调用其他块。无需将$user\u id与false进行比较($user\u id==false)