Hello i have this code and something isn't working but i dont know what, the code it does not updating the database at all and i don't get any errors.
<?php
if(isset($_POST['howMuch']) && isset($_POST['where'])) {
$howMuch = $_POST['howMuch'];
$where = $_POST['where'];
if(!empty($howMuch) && !empty($where)) {
$user_mBalance = getUserData('payCheck');
if($howMuch > $user_mBalance) {
echo "You cannot donate more than you have!";
} else {
$sql = "SELECT `ID` FROM `users` WHERE `First Name`='".$where."'";
$result = $conn->query($sql);
if($result === false) {
trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
if($row = $result->num_rows > 0) {
echo "Username doesn't exist.";
} else {
$sender = getUserData('First Name');
if($where == $sender) {
echo "You can't donate to your self!";
} else {
$total = $user_mBalance - $howMuch;
$query = "UPDATE `users` SET `payCheck`='".$total."' WHERE `First Name`='".$sender."'";
$res = $conn->query($query);
printf("You have donated $ %d to %s", $howMuch, $where);
}
}
$conn->close();
}
}
} else {
echo "You can't leave empty! ";
}
}
?>