Код: Выделить всё
include_once "database.php";
include_once "cores.php";
$phone = $_POST['phone'];
$select = "SELECT * FROM `client` WHERE `phone`='$phone' AND `status`='Active' ";
$run = mysqli_query($connect, $select);
if (mysqli_num_rows($run) > 0)
{
$userData = array();
while ($row = mysqli_fetch_assoc($run))
{
$userData = $row;
}
echo json_encode(
array(
"check" => true,
"userID" => $userData[0]
)
);
}
else
{
echo json_encode(array("check" => false));
}
Код: Выделить всё
Future LoginClient() async
{
if (phone.text.isNotEmpty)
{
try
{
var validate = await http.post(
Uri.parse(ApisConnect.checkPhoneNumberApi),
body: {
"phone" : phone.text
}
);
var response1 = jsonDecode(validate.body);
if (response1["exists"] == true)
{
var login = await http.post(
Uri.parse(ApisConnect.loginApi),
body: {
"phone": phone.text,
},
);
var response2 = jsonDecode(login.body);
if (response2["check"] == true)
{
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => DashboardScreen()));
User userInfo = User.fromJson(response2["userID"]);
Fluttertoast.showToast(msg: 'Logined Successfully,');
}
else if(response2['check'] == false)
{
Fluttertoast.showToast(msg: 'You Are blocked, If you have any error call Techneical Support');
}
}
else
{
Fluttertoast.showToast(msg: 'This Number not signed, sign up first.');
}
}
catch (e)
{
Fluttertoast.showToast(msg: 'Error: $e');
}
}
else
{
Fluttertoast.showToast(msg: 'Fill The field first');
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... th-php-api