-2
Personal need a lot of help I have an input for the person to make a money transfer but if that person has 30 real money and she type a value of 100 real to make the transfer she will be with balance -100 I just want her to be able to transfer as much money as is in the database
Code I use to transfer the user to the bank
<div class="tab-pane" id="thee-tab">
<p><form method="POST" action="?pagina=setting">
<center>
<select name="id">
<?php
$result_usuario = "SELECT * FROM `usuarios` WHERE id=1";
$mostra_dados = mysqli_query($conn, $result_usuario);
while($rows_cursos = mysqli_fetch_assoc($mostra_dados)){ ?>
<option value="<?php echo $rows_cursos['id']; ?>"><?php echo $rows_cursos['usuario']; ?></option>
<?php } ?>
</select>
Dinheiro: <input type="text" name="dinheiro" max="<?php echo $rows_cursos['dinheiro']; ?>">
Code I use to update the database by decreasing the user’s input value and adding the account to the database
$id = $_POST['id'];
$dinheiro = $_POST['dinheiro'];
$_SESSION['id'] = $id;
$_SESSION['dinheiro'] = $dinheiro;
$recebe_dados1 = "UPDATE usuarios SET dinheiro = dinheiro -'$dinheiro' WHERE id = '".$_SESSION['usuarioId'] ."'";
$recebe_dados2 = "UPDATE usuarios SET dinheiro = dinheiro +'$dinheiro' WHERE id = $id";
$recebe_dados3 = "UPDATE usuarios SET depositado = depositado +'$dinheiro' WHERE id = '". $_SESSION['usuarioId'] ."'";
I suggest editing the question using punctuation appropriately. Your question is unreadable.
– William John Adam Trindade
If the user has 100 real then he can only deposit in maximum 100 real understood? in my case if the person has 100 real and she make a transfer of 500 real her balance will be -400
– mateus silva
Possible duplicate of How to make a condition with mysql php number
– Thiago Magalhães