I believe this can be solved as follows:
$hora = time();
$id = //id qualquer;
$seulink = "ativacao.php?id=" . $id . "&hora'=" . $hora;
And in the active.php file you do the logica to check if the parameter $hora
has a difference of more than half an hour from the current time. If it is larger, it does not allow activation.
You can also generate a hash based on the value of the current time and the ID (to prevent the user from changing the value of &hora
manually) and validate whether that hash is possible at the time of checking in.php.
Since you want to disable the link after the first use, you can create a table in the database with two columns: id
and jaUtilizado
(Boolean) and the ativacao.php
would make a select in the database by id passed via parameter in the url. If the column jaUtilizado
is marked for that Id the activation for that point. If it is not marked, mark it and continue with the process.
You can use a flag in the database that it has already been accessed or even change the generated date to 30 minutes ago, so it will stop working too.
– Mastria