1
I have a problem that my href
does not recognize the link coming from the database.
For example if I put www.facebook.com in the database, when I call it inside the href
he brings me href="localhost/projeto/www.facebook.com"
, but if I take the facebook link https://www.facebook.com/ and put in the database when I call on href
he returns to me like this href="https://www.facebook.com/"
In other words, it returns the correct link.
someone knows what I have to do to href
recognize www.facebook.com as a link?
I think your problem is the lack of protocol
http://
,https://
in front of the link probably your link this way<a href='facebook.com'>
should be<a href='https://facebook.com'>
– Icaro Martins
then but then and that’s not me who will manage it I have no way of knowing if the person who will administer will use the protocol, why it would be simple to just put the
https://
before the content she types.– Wagner
It is up to the programmer to process the data sent via input and to define if what the user typed is correct! the problem is probably what @Icaromartins mentioned, I would try to treat this input to not let you save the url without http!
– Lodi
I think it would be good for you to treat this on the server side by checking whether the user will type http or not when saving.
– Daniel Aloísio
Knowing that it will be a link, in reading the data (before putting the
a href
) Voce can remove thehttp://
orhttps://
and put only the//
as in the example<a href="//facebook.com">
if I’m not mistaken this should work fora href
also, it will automatically select the protocol based on the current page– Icaro Martins
understood did not know that only the
//
worked I always thought I should specify.– Wagner