validating url


Posted on 16th Feb 2014 07:03 pm by admin

im trying to validate url's sent to me by a form
the url's im collecting are for placing banners on my site
so the url's are the link to there site and url of where there banner is

URL's ARE BROKEN INTO PARTs PROTOCOL/SUBDOMAIN/DOMAIN NAME/DIRECTORY/FILE

SO FAR I GOT
Code: if(!preg_match("/^http://www.[a-z0-9-].[a-z]{2,3}[a-z0-9/.] $/i", $_POST[url]))
This checks the form feild url
1) make sure http://www. is present (i dont see why it should be any different for the purpose of my use)
i wll be placing a warning on my form page that the urls must contains this

2) Then my code checks it consists of only letters,numbers,dashes/hythens i read these are the only characters a domain name can be
also they must start with a letter or number so how do i make that possible?

3) the next part makes sure theres a .
4) the next part makes sure it consists of only letter of 2-3 characters long
this only alows things such as .com or .ru
How do i alow multiple for example .co.uk
5) i then want to make the rest optional but to alow
letter/numbers/for directories . for start of ext

can anyone help me tweak my code to satisfy my needs but to be as strict as possible.

also knowing what my code is going to be checking is there any genuine urls that the code would refuse
or is there anything i need to know

No comments posted yet

Your Answer:

Login to answer
304 Like 20 Dislike
Previous forums Next forums
Other forums

Transaction variant for VA02 not working
My requirement is to have transaction for user to only add the output and print a sales order.

MFC GUI Programming
I am working on a project right now that requires me to create a MFC Windows GUI. Basically it need

"From field" in PHP email form
I used a wizard to create a PHP email form. I was able to customize it with the exception of the Fr

Run function every 5 mins ??
I have a function PostMessage()

How can I run it every 5 mins ??

Small problem with image resize script
Hi!

I am a little bit new to php and I have an issue installing an image resize script I down

Performance impact of cookies
Hi, I was just wondering what impact there would be in terms of performance if you where to set then

Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to

writing my own sobel filter convolution - something is wrong
I am trying to keep it very simple, I cant see anything wrong with my logic, could anybody help poin

Can I call a class inside a function?
I have a class written in another file that handles my image resizing.

Can I do this (php say

Socket Server Response Headers
Earlier I had a post about my Socket Server, I wasn't able to get it to connect, now I can

I

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash