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

Did you know?Explore Trending and Topic pages for more stories like this.
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

(sub)screen resize modification doesn't work after ECC 6 EhP 4 installation
Hello,

We have previously extended the size of the custom data tab on PO transaction ME23

Parse error: parse error in C:wampwwwlogspagesmembers.php on line 16
I dont see the problem with this, I always get Parse error: parse error in C:wampwwwlogspagesme

help finding hacking loopholes
i was attacked by a redirect php injection

my pc is clean of viruses

so i figure that

problem in program for counting no of chars using pointers
Hi all, I was trying to make a program which counts number of chars in a string using concpt of poin

please help me in this update statment
hi every one

if I have table and this data in it

id name
10

displaying email without attracting a ton of spam
Hello,

this is maybe the wrong place to ask.
How would you display an email address on a w

C problem struct and string
Hi guys,

This is my first post and I'm hoping the experts here can help me solve my problem.<

passing data from one page to another
hey guys
i have the follwoing code to get information from one page and place on another:

php not working written for consumption of slots
1. Here is the function where i will be allowed to consume the slot booked by me.

2. Here i c

How to read CSS message data
Hi,
I have a requirement here. When working as a Dev angel for multiple customers its really di

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