Welcome to WebmasterWorld Guest from

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


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 [....]



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

WebmasterWorld Senior Member 10+ Year Member

you can use the strpos() function


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:

Not using Regular Expressions and why is briefly discussed.


Featured Threads

Hot Threads This Week

Hot Threads This Month