PHP Security: Validating NumberTag: security, validation, number, integer, float Category: PHP Securitypost: 27 Feb 2008 read: 316 PHP Security Number Validation Tips - Part 1: You get a project about accounting system. Your client is big company. They produce exclusive secure car for militer. The price is $ 100,000. One day, they get order from departement of defence all the world. Total order 200,000! But, they become too panic. Not about order, but your software really make them mad. Why? Accounting staff enter number: 200,000. One car is $100,000. When they try to produce report, total omzet become:
What's going on? Total omzet must be:
Let's analyze what happen. You write code like this:
Oh, this is problem source. You just limit them with integer. When they input like this:
The result is -1474836480. The maximum value that can be contained in a PHP integer depends on the bit-size of your processor. On 32-bit systems, the largest integer is a mere 2,147,483,647.
for this jobs, you can use like this:
You client should be more bigger. But, because your software, they can be bankrupt. he he he...
|
| | Give Your Opinion | Recommend |
|

