Files
Siro/walletintaleq.intaleq.xyz/v2/main/auth/captin/login.php
2026-06-11 18:22:59 +03:00

67 lines
1.7 KiB
PHP

<?php
include "../../connect.php";
$email = filterRequest('email');
$phone = filterRequest('phone');
$password = filterRequest('password');
// Hash the password
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$sql = "SELECT
driver.id,
driver.phone,
driver.email,
driver.password,
driver.gender,
driver.birthdate,
driver.site,
driver.first_name,
driver.last_name,
driver.education,
driver.employmentType,
driver.maritalStatus,
driver.created_at,
driver.updated_at,
email_verifications.verified
FROM
driver
LEFT JOIN email_verifications ON email_verifications.email = driver.email
WHERE
driver.phone = :phone AND driver.email = :email ";
$stmt = $con->prepare($sql);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':phone', $phone);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$count = $stmt->rowCount();
if ($count > 0) {
$stored_password = $data[0]['password'];
if (password_verify($password, $stored_password)) {
unset($data[0]['password']);
echo json_encode([
"status" => "success",
"count" => $count,
"data" => $data
]);
} else {
// The password is incorrect
echo json_encode([
"status" => "Failure",
"data" => "Incorrect password."
]);
// printFailure("Incorrect password.");
}
} else {
// The user does not exist
echo json_encode([
"status" => "Failure",
"data" => "User does not exist."
]);
// printFailure("User does not exist.");
}
$conn->close();
?>