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)

Junior Member

10+ Year Member

joined:Mar 9, 2006
votes: 0


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 15, 2004
votes: 0

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)

Junior Member

10+ Year Member

joined:Sept 10, 2004
votes: 0

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)

Senior Member from US 

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

joined:Apr 14, 2008
votes: 62

Duplicate thread:

Not using Regular Expressions and why is briefly discussed.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members