I am making my website secure to SQL Injections, so I am using prepared statements. But do I also need this when updating value? I have a text input where value comes from the current row value. In button click, this is how I save the new value in the text input:
HTML:
<form method='post' action='xtest.php'>
<input type='hidden' name='hidden_id' value='{$row['id']}'> <!-- id without url ref: https://stackoverflow.com/a/32278030/14266656 -->
<td><input type='text' name='note' id='note' value='{$row['note']}'></td>
<td><input type='submit' name='btSubmit' value='Submit'></td>
</form>
PHP (xtest.php):
$action = $_POST['btSubmit'];
if ($action == "Submit") {
$id = $_POST['hidden_id'];
$note = $_POST['note'];
$sql = "UPDATE table SET note = '$note' WHERE id = $id";
if ($link->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $link->error;
}
$link->close();
}
Am I doing this secure, or do I need to change things up?