Loan - Online Loans - Loans - Loans - Mobile Phones

PDA

View Full Version : HELP! PHP preg_match URL


highborn
Feb 17th 2008, 11:04 pm
Hi,

I need help about preg_match URL.

Here is my problem.

How can I validate form if a user input this in the form. ex. http://www.domain.com or www.domain.com

The form should only accept domain.com.

if the http://www and www. are exists in the user's input the php code should output error like

"Must not contain http:// and www."

if the input is valid script continue.

Hope someone could help me about this.

Thanks,

Highborn

decepti0n
Feb 17th 2008, 11:54 pm
Instead of that, why not just strip it out? if you take out the http:// and www., then it can continue even if they do add it


$domain = str_replace(array('http://', 'http://www.'), '', $_POST['domain']);


Not too sure, but it'd remove the http and the http://www, if you only stripped the www. they could have (for example) blawww.com and it'd be removed.

highborn
Feb 18th 2008, 12:21 am
thanks for the reply but I would like to learn how preg_match work on validation.