0
I have a function that captures the ID of the URL and makes the query in DB and returns the value on the page, how to do this query without appearing the ID in the URL?
Currently this way:
How to Hide the ?id=9991
from the URL to is just like this:
I’ll leave the function here, but I think the function itself adds nothing to the question.
function protetor() {
$conexao = mysqli_connect("127.0.0.1","root","","protetor");
$id = $_GET['id'];
$dados = mysqli_query($conexao, "SELECT * FROM download WHERE ID = $id");
$download = mysqli_fetch_array($dados);
if (!empty($id)) {
echo $download['link'];
} else {
echo "Link de download não encontrado!";
}
}
nome-do-post
is a unique value for registration? To do what you want, it will need to be unique. Read on Slug and friendly Urls.– Woss
in case I add the
?id=9991
just so the function know what it has to look for in the table, this is not part of the post, doubt and how I can make the function detect this ID without I have to add it at the end of the URL– Vitor Hugo
Exactly. Without the id, the only information will be
nome-do-post
, then that amount will have to be enough for you to find the registration in the bank.– Woss
Wouldn’t there be a way to pass this ID so it can be captured by a cookie and then take it directly from the cookie? like, redirect the ID this way, but after the page captures the ID it refreshes and saves the cookie, it would be possible to do this?
– Vitor Hugo
And why not do it the easy way (and correct)?
– Woss
@Anderson being very honest with you, I have no idea how to do this, like, I’m not familiar with these HTACCESS rules, but thanks anyway, I’ll try to take advantage of that information.
– Vitor Hugo
In the first comment I gave you the tips of what you need to study. htaccess is one of the ways used. Focus first on understanding the concept, then try to apply it. If you go straight to htaccess and try to do without understanding what you are doing it will be a bad experience.
– Woss