用户不存在的错误消息,php

用户不存在的错误消息,php,php,html,Php,Html,我正在尝试构建一个web应用程序。当用户尝试登录,但电子邮件不存在或密码不正确时,它将保留在索引页。我想要的是,当电子邮件不存在或密码不正确时,保留在索引页,并在该页中显示消息:“电子邮件不存在”…我尝试了很多方法,但到目前为止没有任何功能…我的代码如下: <?php mysql_connect("127.0.0.1","root","") or die("Smund te lidhet me serverin"); mysql_select_db("axhend

我正在尝试构建一个web应用程序。当用户尝试登录,但电子邮件不存在或密码不正确时,它将保留在索引页。我想要的是,当电子邮件不存在或密码不正确时,保留在索引页,并在该页中显示消息:“电子邮件不存在”…我尝试了很多方法,但到目前为止没有任何功能…我的代码如下:

   <?php 

    mysql_connect("127.0.0.1","root","") or die("Smund te lidhet me serverin");
    mysql_select_db("axhenda") or die("Kjo databaze nuk u gjet");

    if (isset($_POST['submit'])) {//kontrollo per  butonin submit
    $Email=$_POST['email'];//variable ang $Username kag ang $_POST['UserName'] ay value sang textbox nga UserName
    $Fjalekalimi=$_POST['pass'];//variable ang $Username kag ang $_POST['Password'] ay value sang textbox nga Password


    $result = mysql_query("SELECT *  FROM perdoruesi where Emaili = '$Email' AND  Fjalekalimi = '$Fjalekalimi'") or die("Kjo query nuk mund te plotesohet");

    $count=mysql_num_rows($result);//isipon kn may tyakto sa query
    $row=mysql_fetch_array($result);//ma return row sa database

            if ($count > 0){//kun may tyakto sa query e execute yah ang code sa dalom
            session_start();//para mag start ang session
            $_SESSION['user_id']=$row['Id_Per'];//kwaon ang id sang may tyakto nga username kag password ang ibotang sa $_SESSION['member_id']
            header('location:home.php');
            }
else{
            header('location:index.html');
            }
    }

提前感谢…

我会将index.html更改为index.php,然后将它们重定向到index.php?error=1之类的内容
在index.php中,我会检查isset($\u GET['error'])和($\u GET['error']==1,您可以输出一个错误。不过这是我的简单方法。

使用错误消息设置会话变量。然后重定向到index.php,在那里检查会话变量是否已设置。如果已设置,则显示错误消息并清除会话变量。

在您的情况下:

if ($count > 0){
    session_start();
    $_SESSION['user_id']=$row['Id_Per'];
    header('location:home.php');
}else{
    header('location:index.php?error=404');
}
然后在index.php中

if($_GET['error']==404){
    echo "Email does not exist";
}

在继续工作之前,请帮自己一个忙,并告知自己SQL注入和准备好的语句。但是没有……我尝试过这个……但它没有显示任何内容……因为当我按submit时,索引页只是重新加载……我想在索引页上放置一个标签,并使其显示为dispay:none,在sigin.php页上使其显示Document.getElementById('labelid').style.display='block'..但我担心它不会识别labelid…谢谢…它真的很有帮助
if($_GET['error']==404){
    echo "Email does not exist";
}