homepage Welcome to WebmasterWorld Guest from 54.204.249.184
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
validate form help
need to check how value starts
weddingm




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

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

 

omoutop




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

you can use the strpos() function

or

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

JohnCanyon




msg:4018499
 8:24 pm on Nov 3, 2009 (gmt 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.';
}

TheMadScientist




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

Duplicate thread:
[webmasterworld.com...]

Not using Regular Expressions and why is briefly discussed.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved