I can't seem to find anything on this, nor can I fix it my self after trying for hours!
The code is this:
function generatecode()
{
$token = md5(uniqid(rand(), true));
return $token;
}
$number = $_POST['number'];
$service = $_POST['service'];
$token = generatecode();
if ($service == ""){
}
else {
for ($x = 0; $x <= $number; $x++) {
$con = mysql_connect($host,$username,$password);
mysql_select_db("$db_name", $con);
mysql_query("INSERT INTO tokens (id, token, service, used, usedby) VALUES(NULL, '$token','$service','0','')");
}
}
The code above is suppose to generate a string randomly as many times as you want with a simple integer[POST].
When it loops it all it comes out with only 1 unique id when they're should have been (5),
and the 1 id will be the same for all the strings(31a66b9885dba85316d399d6e898b308), so it looks like this:
- 31a66b9885dba85316d399d6e898b308
- 31a66b9885dba85316d399d6e898b308
- 31a66b9885dba85316d399d6e898b308
- 31a66b9885dba85316d399d6e898b308
- 31a66b9885dba85316d399d6e898b308
If anyone understands what i'm trying to say, please leave a comment on how to fix this, thanks!