0
Think about this, I’m creating a code "363636". With this code, I’m giving the client the option to type in the input. However, I want this code to be executed only once. That is, when it enters the code in the input, it is over. If it passes this code to someone else using this script it is no longer accepted. The code I did was the following.
I created a variable called $prenchimento, with the coupon code.
$preenchimento = "363636"; // CUPOM
So I created another variable called coupon, where you get the fill variable
$cupom = $preenchimento // NÃO MEXER
In the form, I am picking up the information via $_POST. That is, when the customer enters the coupon he does the check via if. Always checking if the digital value corresponds with the variable $coupon :
if($tipodeinscricao == $cupom) {
echo "Cupom Validade";
}else{
echo "Cupom não validado";
}
The viable $type registration is the one being picked up from the customer via $_POST. As I said, I need the customer to use this code only once, how can I do that ?
You need to store this value somewhere to check if it has already been typed. It can be a database, a cookie, a Sesssion, for example... the latter two do not guarantee security... for example, the cookie can be deleted, the Sesssion can be expired when closing the site...
– Sam
There is no other way ?
– EuSou Noob
If you want to save the value permanently, only with a database. The tb cookie works, but if the guy understands this, he can delete it easily.
– Sam
How could I do with the cookie ?
– EuSou Noob
Ah, you can create a file on the server and save information on it.
– Sam
To use cookies, use the function setcookies, but in your case the ideal is database, example Sqlite.
– Valdeir Psr
The cookie would not work, because if you use the code in another browser would be validated.
– Sam