SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form validation in php

    Pls, is there are any i could validate the input into a form , say user should only enter numerals rather that string xters from PHP

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use is_numeric (http://uk.php.net/is_numeric) to check if a value is numeric or not. For more complicated form validation, I.e checking a valid email address you would probably do so using regular expressions.

  3. #3
    SitePoint Addict RRWH's Avatar
    Join Date
    May 2005
    Posts
    269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    start with http://php.net/manual/en/function.is-numeric.php and go from there....

  4. #4
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,561
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To get ease yourself from all the pain involved in form validation, use QuickForm package of PEAR. Yes, it might be a bit difficult to grasp to begin with, but as you do it for sometime itís breeze.

  5. #5
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kailash Badu
    To get ease yourself from all the pain involved in form validation, use QuickForm package of PEAR. Yes, it might be a bit difficult to grasp to begin with, but as you do it for sometime itís breeze.
    Until you come to a situation where you cant use Pear, then all of a sudden you dont know how to validate input. For someone, who is obviously fairly new to PHP it would be more beneficial to learn how to validate input alone.

  6. #6
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,561
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Until you come to a situation where you cant use Pear, then all of a sudden you dont know how to validate input
    It hardly happens, I suppose. Even when you use Pear, you easily know how exactly the validation is working. All the rules are written under Rule class, which simple uses general preg_match() against different regex values. In case you donít have pear, you can easily rewrite those function inside your own form validation page. I have found it easier then I expected.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •