Two approaches - personally, I'd make it so they *can't* enter anything more than what's in stock, probably using a drop down field for the Quantity. So, on load the form checks how many there are in stock etc, then you could use something like:
<?php
//Pseudo code, this probably won't work as is
$quantity = $find_set('Quantity');
$dropdown = "";
for ($i = 1; $i <= $quantity; $i++) {
$dropdown .= "<option value=\"".$i."\">".$i."</option>";
}
?>
<select name="quantity">
<?php echo $dropdown; ?>
</select>
If this isn';t really applicable, then you can check on submission - the way you outline should work, except you can't just transfer variables between pages. And if the $REQUEST['Database_Quantity'] isn't set from the form in the first place, then it won't work either. And I wouldn't use the FMS redirect, just a normal location header
<?php
session_start; //Required to have a session variable that can transfer between pages
if( $_REQUEST['Quantity_Entered'] > $_REQUEST['Database_Quantity']
){
$_SESSION['message'] = 'The amount Sold exceeds the amount in stock';
header("Location: form.php'.'?Record_ID='.$_REQUEST['Record_ID']");
//This assumes that the form page uses a Record_ID for a search on load, *and* that the form has passed that value to the handling page
}