Jump to content

Check Integer or not


austine_power007

Recommended Posts

use regular expression

link for javascript [url=http://www.phpfreaks.com/javascript_manual/page/regexp.htm]http://www.phpfreaks.com/javascript_manual/page/regexp.htm[/url]
link for php [url=http://www.phpfreaks.com/phpmanual/page/ref.regex.html]http://www.phpfreaks.com/phpmanual/page/ref.regex.html[/url]
Link to comment
https://forums.phpfreaks.com/topic/29767-check-integer-or-not/#findComment-136681
Share on other sites

[quote author=mansuang link=topic=117681.msg480292#msg480292 date=1165466668]
use regular expression

link for javascript [url=http://www.phpfreaks.com/javascript_manual/page/regexp.htm]http://www.phpfreaks.com/javascript_manual/page/regexp.htm[/url]
link for php [url=http://www.phpfreaks.com/phpmanual/page/ref.regex.html]http://www.phpfreaks.com/phpmanual/page/ref.regex.html[/url]
[/quote]

I am new in php and tht don't have much example..........so please send me some easy code so that will be easy for me......sorryy i m NUT
Link to comment
https://forums.phpfreaks.com/topic/29767-check-integer-or-not/#findComment-136712
Share on other sites

For checking the form submission using PHP you could try something like:

[code]
if (!preg_match('/[^0-9]+/',$FORMVARIABLE)) {
  //error code goes here
}
else {
  //process code here
}

[/code]

I haven't tested this, but it should reject everything that's not an integer.  You'll just have to fill in the $FORMVARIABLE with your actual variable and then write the error and process code.
Link to comment
https://forums.phpfreaks.com/topic/29767-check-integer-or-not/#findComment-136717
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.