Lucas Lucas - 1 year ago 65
PHP Question

How can I limit the max value of number?

I want to secure my page by checking if the value is digital (0,1,2,3) and if it is in the range from 0 to 120. I think

function limits numbers, so can not be passed any negative number. How can I limit the max value in the simplest way?

if (!ctype_digit($_GET['category'] AND ...) die('');

if (!ctype_digit($_GET['category'] > 120) ?

I was thinkig about
but it can pass negative numbers.

Answer Source
if (!ctype_digit($_GET['category']) || $_GET['category'] > 120) die('')

Basically this says "If it's not a number or if it's larger than 120, stop"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download