Skip to content

Instantly share code, notes, and snippets.

@brunolimadevelopment
Created July 5, 2018 14:04
Show Gist options
  • Save brunolimadevelopment/14fa55f4781c6863085f16abf5f0af32 to your computer and use it in GitHub Desktop.
Save brunolimadevelopment/14fa55f4781c6863085f16abf5f0af32 to your computer and use it in GitHub Desktop.
<form method="post">
<input type="submit" value="Comprar"/>
</form>
<br/>
<h2>Código do cupom</h2>
<br/>
<?php echo generateRandomString(); ?>
<?php
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment