Hello everybody, What i need get done is checking if a url is already submitted in database using php.
I have a database table where i store URLS submitted by users. But i want to check if the urls are already submitted or not in the database before inserting it to the database. For example, URLS like http://www.example.com, http://www.example.com/, http://example.com and http://example.com/ should return false if any one of them is already inserted in database as they all are same urls. I think we can get this done by using regular expression.But i am a little weak in regex so need your help. thank you
Edited
Hello, let's assume if the urls are in array not database just to make clear. I know about the unique key and matching url with the result from database. But here i have a
different question if you look at it carefully.
$urls = array('http://www.example.com/newpage.html', 'http://www.example.com/newpage.html');
case A user submits a url. suppose http://example.com/newpage.html
Now as a url http://www.example.com/newpage.html is available in $urls array and http://www.example.com/newpage.html and http://example.com/newpage.html(userinput without www) are same page so i need a function to check it and return false if the url is available in the array. I hope i clarified my self now.
So it's not checking a domain or making unique key in mysql table for url field i think so far. I think we need to use regExp for it. Any help?