Hello,
I've made up a small online auction but I've got one small problem. The user fills in a form with their info and their Bid amount, but for the bid I only want them to submit a dollar amount with numbers only. NO cents, no decimals, commas etc. I only want numbers from 0-9. A bid of 255 is good, but 255.50 is not.
So when the user submits the form, they go to a "Confirm Bid" page which shows the info and Bid they are about to submit. On this page I'd like to notify them if their Bid is incorrectly formatted and give them a chance to go back and fix it.
So on the confirm page I call the bid amount with:
<?php echo $bid_amount; ?>
Next to the bid amount I'd like to have "Invalid Bid - Please go back..." appear if the bid is not strictly numbers, and have nothing appear if the bid is fine. ie:
123.25 Invalid Bid - Please go back...
123
I think this code is what I'm supposed to be using but am not sure how to use it:
<?php if (preg_match('/[0-9]{3,4}/', $bid_amount){
echo "Invalid Bid - Please go back..."; } ?>
Can you see what's wrong with this?
Thank you very much.
Peter