-1
これはおそらくあなたにとって非常に単純な問題です。私は十分なポイントを持っているかどうかを確認するために、データベースをチェックするPHPコードを使用しようとしています。その後、彼らは十分なポイントを持っている場合は、そこからポイントを差し引く。 これは私が現在、それが動作していない使用しているものです:php/mysqlを使ってポイントをチェックして差し引く
<?php
$con = mysqli_connect("localhost", "id177667_root", "***", "id177667_loginb");
$response = array();
$statement = mysqli_prepare($con, "SELECT * FROM user WHERE username = ?");
mysqli_stmt_bind_param($statement, "s", $_POST["username"]);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $userID, $name, $username, $password, $points);
$pointsint = (int)$points;
if ($pointsint > 12500){
$statement = mysqli_prepare($con, "UPDATE user SET points = points - ? WHERE username = ?");
mysqli_stmt_bind_param($statement, "is", 12500, $_POST["username"]);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $userID, $name, $username, $password, $points);
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["name"] = $name;
$response["username"] = $username;
}
}else{
$response["success"] = false;
}
echo json_encode($response);
?>
なく、あなたを探すために今十分な時間問題ではなく、アドバイスとして:ユーザーからすべてのデータを選択しないでください。 Select * from From ...単に「Select point from FROM user」というだけではないのですか? Rellaはパスワードとそのすべてのものを読み込む必要はありません。 – Twinfriends