Welcome to WebmasterWorld Guest from 54.159.179.132

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

validate form help

need to check how value starts

   
7:11 am on Nov 3, 2009 (gmt 0)

5+ Year Member



Hello,

I need help writing a code that will check if the first characters are http. I am accepting web adresses but don't want any values entered with the [....]

Thanks,
Matt

10:57 am on Nov 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you can use the strpos() function

or

str_replace("http://", '', $my_string);
This will work even if no http is present

8:24 pm on Nov 3, 2009 (gmt 0)

10+ Year Member



If you wanted to display a message to your user, you could use a regex expression to check to see if http:// is present.

if(preg_match("/^http:\/\//i", $input)) {
echo 'Sorry, http:// is invalid input.';
}

3:26 am on Nov 4, 2009 (gmt 0)

WebmasterWorld Senior Member themadscientist is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Duplicate thread:
[webmasterworld.com...]

Not using Regular Expressions and why is briefly discussed.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month