"";
$dbname = "u2728808_lios.space";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Проверка существования пользователя в базе данных
$sql = "SELECT * FROM users WHERE username = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $username);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
// Пользователь существует, возвращаем "Login success"
echo "Login success";
} else {
// Пользователь не существует, возвращаем "Login failed"
echo "Login failed";
}
// Получение данных из POST-запроса
$username = $_POST['username'];
$password = $_POST['password'];
$uuid = $_POST['uuid'];
$manufacturer = $_POST['manufacturer'];
$model = $_POST['model'];
// Обновление столбцов в таблице users
$sql = "UPDATE users SET password = ?, uuid = ?, manufacturer = ?, model = ? WHERE username = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sssss", $password, $uuid, $manufacturer, $model, $username);
$stmt->execute();
// Возвращаем "Login success"
echo "Login success";
$stmt->close();
$conn->close();
?>
Нужно, чтобы если username верный вносились password , uuid, manufacturer, model. А при каждом запуске приложения проверялись username, password , uuid, manufacturer, model и если совпадают то возвращало login success
<?php // Connect to the database $servername = "localhost"; $username = ""; $password = ""; $dbname = "u2728808_lios.space"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Check if the user exists in the database $sql = "SELECT * FROM users WHERE username = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("s", $username); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { // The user exists, return "Login success" echo "Login success"; } else { // User does not exist, return "Login failed" echo "Login failed"; } // Receiving data from a POST request $username = $_POST['username']; $password = $_POST['password']; $uuid = $_POST['uuid']; $manufacturer = $_POST['manufacturer']; $model = $_POST['model']; //Updating columns in the users table $sql = "UPDATE users SET password = ?, uuid = ?, manufacturer = ?, model = ? WHERE username = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("sssss", $password, $uuid, $manufacturer, $model, $username); $stmt->execute(); // Return "Login success" echo "Login success"; $stmt->close(); $conn->close(); ?> It is necessary that if the username is correct, enter password, uuid, manufacturer, model. And every time the application was launched, username, password, uuid, manufacturer, model were checked and if they matched, it returned login success
Обсуждают сегодня