Good evening, I'm trying to do a check on my site. If the client balance, which is set by a $ _SESSION.
If it has a balance lower than the price of the product, it would have to do this:
$saldo = $_SESSION['saldo'];
$procuraPreco = mysqli_query($connect, "SELECT preco FROM infs WHERE id='$id'");
$retornaPreco = mysqli_fetch_all($procuraPreco,MYSQLI_ASSOC);
$preco = $retornaPreco[0]['preco'];
if(isset($_POST['comprar'])) {
if($saldo < $preco) {
die('<script>alert("Pedido recusado. Razão: Saldo insuficiente"); window.location = "shop.php";</script>;');
}
Only the alert is not shown on the page and it only appears in the response (F12):
<script>alert("Pedido recusado. Razão: Saldo insuficiente"); window.location = "shop.php";</script>
Note: I do a POST on the same page that the customer clicks to buy.