SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot JordanTLClive's Avatar
    Join Date
    Feb 2001
    Location
    Las Vegas, NV
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Checking web address

    I need to check that the web address a user inputs is VALID. It needs to have http://, https:// or whatever you may have there, followed by the website with no spaces. How can I do this?

    Actually I need to check for a valid email address too.
    Last edited by JordanTLClive; Jun 5, 2001 at 19:28.
    -Jordan

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try doing a search for email validation on this forum.

    As for the regular expression you need.

    PHP Code:
    $url "<br>[url]www.somedomain.com[/url]";

    /*
    This first one prints "has it" if the 
    [url]http://[/url] or [url]https://[/url] is present
    */
    print (eregi("(http|https)://"$url)) ? "has it<br>" "doesn't have it<br>";

    /*
    This one prints "has spaces" if the 
    domain has space in it.
    */
    print (eregi("[[:space:]{1}]"$url)) ? "has spaces<br>" "doesn't have spaces<br>"
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •