I have created a simple HTML form for submitting an amount of money that should be deposited into an account. The form consists of a number input and a submit button.
When I press the submit button after inputting 10
in the input box I get this following error message:
Error updating record: Unknown column 'deposit' in 'field list'
I don't have such a column in my table as can be seen on the following image:
Welcome to the Bank! <br><br>
<table bgcolor="orange" border="1" cellspacing="0" cellpadding="50">
<tr><td>
<form action="" method='post'><b>Amount of money you want to deposit:</b><br><br>
<input type='number'><input name ='deposit' type='submit' value='deposit'></td></form>
<?php include 'db.php';
if (isset($_POST['deposit']))
{
$deposit = $_POST['deposit'];
$sql = "UPDATE bank SET bank = bank + $deposit, cash_on_hand = cash_on_hand - $deposit WHERE id=1";
if ($conn->query($sql) === TRUE)
{
echo "Record updated successfully"; /*Money Deposited successfully!*/
}
else
{
echo "Error updating record: " . $conn->error;
}
$conn-> close();
}
?>