Forum Moderators: coopster
I have a PHP survey across multiple pages, and have been using people's e-mail addresses to identify them and put the different mysql tables together later. However, if two people decide not to provide an e-mail address I don't know which responses go with which person.
Is there a way I can generate a unique random number which I can hide in each form across the pages?
Many thanks
Ed
$var = str_replace('.', '', uniqid($_SERVER['REMOTE_ADDR'], TRUE)); Depending on how long the IP address is this will return a string up to 35 characters long that is based on microseconds. If two users happen to click the link at the same microsecond (not too likely) they will have a different IP address tagged onto the front.
- Ryan
$random= "";srand((double)microtime()*1000000);
$block = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$block .= "0123456789";for($i = 0; $i < 10; $i++)
{
$random .= substr($block,(rand()%(strlen($block))), 1);
}echo $random;
This will (or should) display something like: A6GF85CS3L