I'm using the ereg function to check the validity of a price that can be entered.
I want it so no more than 999.99 can be added.
That is I can have 1-3 digits before the decimal point and only 2 after it. There should always be 2 after it.
The digits after the decimal point seem to work, if I put 2.999 in, rather than having entered 2.99 into the database it'll enter $3.00 (that'll do I suppose)
BUT
if I entere 10000.00 that still enteres the database that is too much.
This is the statement I currently have
if(!ereg("([0-9]{1,3}).([0-9]{2})", $_POST[Price], $regs)){
echo "Invalid Price, Book Not Added";
pageRedirect('sellabook.php');
}
Can someone correct my code for me, please
I suppose I can always write an IF statement preventing values over $999.99