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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.