Jump to content


Photo

validating form input


  • Please log in to reply
2 replies to this topic

#1 sdaniels

sdaniels
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 17 April 2006 - 11:15 PM

I have found some code that validates that a text field has something@something.something to be sure that the user entered an email address in the right format. Only isue is that I do not understand it at all. could someone break it down for me? I tried to tweak the code to validate an IP address but its just not happening for me.


this is the code i have on my site, and it works great, but i dont understand what is going on here.


$eaddress = $_REQUEST['eaddress'];
if (!eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$',stripslashes(trim($eaddress)))) {




#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 17 April 2006 - 11:43 PM

It uses Regular Expressions, which is something I am not good at.
Try to google some Regex tutorials...

This is a Regex you can use to validate IP's:
^(([3-9]\d?|[01]\d{0,2}|2\d?|2[0-4]\d|25[0-5])\.){3}([3-9]\d?|[01]\d{0,2}|2\d?|2[0-4]\d|25[0-5])$

~ D Kuang

#3 sdaniels

sdaniels
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 17 April 2006 - 11:46 PM

thanks for the code, ill end up using it, but i really want to get my mind around how this syntax for this function is supposed to work. Ill try and google it, thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users