I am setting up a simple account generator with HTML and JavaScript, I have been looking for some help, such as limiting to an account per person, that is, if someone wants to generate an account, click on the button and block or with cookies Temporarily disable the generator for that "x" person.
I leave you my sample code
<form name="form_cuenta">
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-user"></i></span>
<div id="tx" class="form-control"></div>
<script>
var client = new XMLHttpRequest();
var result;
var i;
if (getCookie('id')) {
i = getCookie('id');
} else {
i = 0;
}
client.open('GET', 'http://unc3ns0r3d.ml/cuentasnetflix.txt');
client.onreadystatechange = function() {
result = client.responseText;
document.getElementById("tx").innerHTML = result.split('\n')[i];
i++;
}
client.send();
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 1 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function next(i) {
document.getElementById("tx").innerHTML = result.split('\n')[i];
}
function nextl() {
i = getCookie('id');
next(i);
i++;
setCookie('id', i, 8);
}
</script>
</div>
<div class="form-group input-group" style="text-align: center;" id="center">
<hr> Tipo de cuenta:<br /><br />
<select class="form-control chosen-select" name="selector" data-placeholder="Tipo de cuentas">
<option id="c_netflix">Netflix</option>
</select>
</div>
<hr>
<div class="form-group no-margn">
<input type="submit" class="btn btn-success btn-block" value="Generar" onclick="nextl();">
</div>
Good for those who still do not understand my idea, the generator reads a text file but in case I want the line or account that is given no longer appear in the text and with cookies block that generates another account to that person
I was looking in many ways on how to do something like that but I just find it with PHP and DB to make it easier.