登录凭据与frob数据库不匹配 [英] Login credentials is not match frob database

查看:59
本文介绍了登录凭据与frob数据库不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码不起作用。实际的问题是我想检查数据库的登录凭据。什么用户输入id和密码但我的查询没有运行并从数据库检查。请检查我的代码并指导我。







$ servername =localhost;

$ username =root;

$ password =;

$ db =Hosp;

< br $>
$ UserName =;

$密码=;



if(isset($ _ POST [ 'Tusername')&& isset($ _ POST ['Tpassword']))

{

if(!empty($ _ POST ['Tusername']) &&!empty($ _ POST ['Tpassword']))

{

$ UserName = $ _POST ['Tusername'];

$密码= $ _POST ['Tpassword'];



$ conn = mysqli_connect($ servername,$ username,$ password,$ db);

if(!$ conn)

{

die(Connection failed:。mysqli_connect_error());

}



$ squery =选择UserName,登录密码,其中UserName ='$ UserName',密码='$密码';



if($ squery == false)

{

die(mysql_error());

}

$ res = mysql_fetch_row($ squery);

if($ res)

{

echo 登录成功;

}

其他

{

echo错误:。 $ squery。 结果。 mysqli_error($ conn);

}





echo提交成功;

}

其他

{

echo字段必须填写。;

}

}

其他

echo变量名称不匹配。;



? >



我尝试了什么:



i试过这段代码但是没有正常运行。

The code is does not work. the actual problem is that i want to check login credentials from database. what ever user input id and password but my query is not running and check from database.?? please check my code and guide me.



$servername = "localhost";
$username = "root";
$password = "";
$db = "Hosp";

$UserName = "";
$Password = "";

if(isset($_POST['Tusername']) && isset($_POST['Tpassword']))
{
if(!empty($_POST['Tusername']) && !empty($_POST['Tpassword']))
{
$UserName = $_POST['Tusername'];
$Password = $_POST['Tpassword'];

$conn = mysqli_connect($servername, $username, $password, $db);
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}

$squery = "select UserName, Password from login where UserName='$UserName' and Password='$Password'";

if($squery == false)
{
die(mysql_error());
}
$res=mysql_fetch_row($squery);
if($res)
{
echo "login successfull";
}
else
{
echo "Error: " . $squery . "
". mysqli_error($conn);
}


echo "Submit Successfully";
}
else
{
echo "Field must be filled.";
}
}
else
echo "Variable name not matched.";

?>

What I have tried:

i have tried this code but not running properly.

推荐答案

servername =localhost;
servername = "localhost";


username =root ;
username = "root";


password =;
password = "";


这篇关于登录凭据与frob数据库不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆