PHP vs multiserial

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
SPH
Enthusiast
Enthusiast
Posts: 593
Joined: Tue Jan 04, 2011 6:21 pm

PHP vs multiserial

Post by SPH »

Hi,

when selling my game online, it happens after the payment stage where the PHP generates the serial for the game. But on this page, the user can, alas, refresh the page and generate other serails (as many he wants).
How to block this?

THANKS :!:

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
normeus
Enthusiast
Enthusiast
Posts: 475
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: PHP vs multiserial

Post by normeus »

It's usually done with $_SESSION, create a session check if a code already exist otherwise save a code. A little more complex than that but there are scripts that do this, check in https://stackoverflow.com

Code: Select all

<?php
session_start();
if (isset($_SESSION['randomcode']){
header('location:/index.php');
	exit;
}
 $_SESSION['randomcode']=rand(10000,99999);
// rest of your code

?>
More or less an example ( a lot less than more)
Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
User avatar
SPH
Enthusiast
Enthusiast
Posts: 593
Joined: Tue Jan 04, 2011 6:21 pm

Re: PHP vs multiserial

Post by SPH »

Ok thx. i see that today :!:

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: PHP vs multiserial

Post by NicTheQuick »

Don't you write the serial into a database?
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
Caronte3D
Addict
Addict
Posts: 1370
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: PHP vs multiserial

Post by Caronte3D »

The best is to use a database where the user must register and keep her generated serials.
That way you can control how many serials an user have
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: PHP vs multiserial

Post by BarryG »

Make the page email them the serial instead? And then auto-close the page after emailing?
User avatar
SPH
Enthusiast
Enthusiast
Posts: 593
Joined: Tue Jan 04, 2011 6:21 pm

Re: PHP vs multiserial

Post by SPH »

NicTheQuick wrote: Thu Apr 13, 2023 9:01 am Don't you write the serial into a database?
I write the serials in a file.
---

Yesterday, I asked chatGPT how to prevent the refresh of the PHP page and it told me 2 "headers" that I put in the PHP page but, alas, we can still refresh..
PHP:

Code: Select all

<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 1 Jan 2000 00:00:00 GMT");

$serial = substr(str_shuffle(str_repeat("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6)), 0, 6);

$data = $serial.PHP_EOL;
$fp = fopen('php/page_scrab.php', 'a');
fwrite($fp, $data);


$clecd = $serial;


echo '<center> <br><br><br>
Thank you for your purchase. Here is your key : <br><font size="14">'; echo $clecd; echo' </font><br> Thank you kindly note it. You will be asked to activate the game.	</td>
'; 

echo "<br><br><br></center>"; 

?>

<?php 
$_VARS_BACK = '';
$_VARS_PAGE = <<<EOT

EOT;

?>
An email ? Why not...

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: PHP vs multiserial

Post by BarryG »

SPH wrote: Thu Apr 13, 2023 11:38 amAn email ? Why not...
Yep, PHP supports that. That way they get a copy of their serial, too.
Post Reply