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 显示无效的电子邮件和密码错误消息_Php_Codeigniter - Fatal编程技术网

Php 显示无效的电子邮件和密码错误消息

Php 显示无效的电子邮件和密码错误消息,php,codeigniter,Php,Codeigniter,视图:login.php 我在两个地方使用这个视图文件,一个用于用户登录,另一个显示无效的用户和密码消息。下面我提到了一些代码,但它不起作用。就这个问题给我任何建议 <div class="login-content"> /* message to be displayed here: i try this one:<?php if(!(authentication($email,$password) == TRUE)){

视图:login.php

我在两个地方使用这个视图文件,一个用于用户登录,另一个显示无效的用户和密码消息。下面我提到了一些代码,但它不起作用。就这个问题给我任何建议

 <div class="login-content">
/*
message to be displayed here:
 i try this one:<?php if(!(authentication($email,$password) == TRUE)){                          
echo "Invalid email address or password";
               }?>
  */
    <form action="<?php echo site_url('auth/check');?>" method="POST" class="margin-bottom-0" data-parsley-validate="true" onsubmit = "return Validate();" >
     <div class="form-group m-b-15">
    <input type="text" name="txtemail" id="txtemail" class="form-control input-lg" placeholder="<?php echo $language['Email'];?>" data-parsley-required='true' maxlength="95"/>
                            </div>
     <div class="form-group m-b-15">
    <input type="password" name="txtpassword" id="txtpassword" class="form-control input-lg" placeholder="<?php echo $language['Password'];?>" data-parsley-required='true' maxlength="95"/>
     </div>
在login.php视图文件中

<?php
   $satatus = $_GET['status'];
   if($status == 'err'){
?>
//add this div right above the login section
<div>Wrong Username/Password !!</div>
    <div class="login-content">
/*
message to be displayed here:
 i try this one:<?php if(!(authentication($email,$password) == TRUE)){                          
echo "Invalid email address or password";
               }?>
  */
    <form action="<?php echo site_url('auth/check');?>" method="POST" class="margin-bottom-0" data-parsley-validate="true" onsubmit = "return Validate();" >
     <div class="form-group m-b-15">
    <input type="text" name="txtemail" id="txtemail" class="form-control input-lg" placeholder="<?php echo $language['Email'];?>" data-parsley-required='true' maxlength="95"/>
                            </div>
     <div class="form-group m-b-15">
    <input type="password" name="txtpassword" id="txtpassword" class="form-control input-lg" placeholder="<?php echo $language['Password'];?>" data-parsley-required='true' maxlength="95"/>
     </div>
<?php
   }
?>

//将此div添加到登录部分的正上方
错误的用户名/密码!!
/*
要在此处显示的消息:
我试试这个:
*/

它是基于段的URL吗?{LInk}()是的,URL是域\名/控制器\名/函数\名要显示错误消息,您需要像我所做的那样在URL中添加一个参数:“?status=err”我没有得到“?status=err”部分。这就是您在代码中使用的内容,对吗?这会将u带到函数签入身份验证控制器。从何处调用模型以查看条目是否存在?我只是说从模型中创建一个$url,如下所示:当您无法在数据库中找到用户条目时,添加这个'status=err'参数,并在最后重定向到这个$url。然后在视图文件u中可以使用此参数显示错误消息。
public function check(){

    $email      = $this->input->post('txtemail');
    $password   = $this->encrypt($this->input->post('txtpassword'));
    $this->load->model('cmsuser_model');
    $user = $this->cmsuser_model->authentication($email,$password);

    if(!is_null($user))
    {
        $this->session->set_userdata('user', $user);
        $this->session->set_userdata('profile_image',$user->image);
        $this->session->set_userdata('is_manager','0');


        $this->load->model('association_model');
        $table = '';
        $limit = '';
        $order_by = '';
        $group_by = '';
        $start = '';
        $fields = '';
        $where = array();
        $where['created_by'] = $this->session->userdata['user']->cmsuid;
        $dt = $this->association_model->get_all($fields, $where, $table, $limit, $order_by, $group_by, $start);
        $this->session->set_userdata('ass_id', $dt[0]['ass_id']); 

        redirect(base_url('index.php/welcome'), 'refresh');
    }
    else{
      $url=echo base_url('login.php').'?status=err';
      redirect($url, 'refresh');
//this will redirect you to the login page with the parameter status in the url
        }
    exit;
}
<?php
   $satatus = $_GET['status'];
   if($status == 'err'){
?>
//add this div right above the login section
<div>Wrong Username/Password !!</div>
    <div class="login-content">
/*
message to be displayed here:
 i try this one:<?php if(!(authentication($email,$password) == TRUE)){                          
echo "Invalid email address or password";
               }?>
  */
    <form action="<?php echo site_url('auth/check');?>" method="POST" class="margin-bottom-0" data-parsley-validate="true" onsubmit = "return Validate();" >
     <div class="form-group m-b-15">
    <input type="text" name="txtemail" id="txtemail" class="form-control input-lg" placeholder="<?php echo $language['Email'];?>" data-parsley-required='true' maxlength="95"/>
                            </div>
     <div class="form-group m-b-15">
    <input type="password" name="txtpassword" id="txtpassword" class="form-control input-lg" placeholder="<?php echo $language['Password'];?>" data-parsley-required='true' maxlength="95"/>
     </div>
<?php
   }
?>