gpt4 book ai didi

java - onPostexecute 中的字符串比较不起作用

转载 作者:行者123 更新时间:2023-12-01 18:05:41 27 4
gpt4 key购买 nike

以下代码是我出于 Intent 而添加的代码,结果是从我的login.php 返回的内容。但它无法比较成功与否。在任何情况下它都不会进入 if 循环。但它在警报对话框中显示“登录成功”。

@Override
protected void onPostExecute(String result) {
if(result.equals("Login Success")){
Intent intent = new Intent();
intent.setClassName("com.example.soumya.attendance","com.example.soumya.attendance.LoginActivity");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(intent);}
else{
alertDialog.setMessage("No Condition Matched..");
alertDialog.show();
}

}

登录.php

<?php  
require "init.php";
$uname = $_POST["login_name"];
$password = $_POST["login_pass"];
$sql_query = "select name from students where uname like '$uname' and password like '$password';";
$result = mysqli_query($con,$sql_query);
if(mysqli_num_rows($result) >0 )
{
$row = mysqli_fetch_assoc($result);
$name =$row["name"];
echo "Login Success";
}
else
{
echo "Login Failed.......Try Again..";
}
?>

最佳答案

尝试使用 result.contains("Login Success") 而不是 result.equals() 作为 PHP 我最后返回一些符号,例如服务器特定的回车符左右。

关于java - onPostexecute 中的字符串比较不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36615598/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com