Re: Random String Generation
| From: | Justin French | Date: | Wed, 12 Mar 2003 22:43:03 +0000 |
| Subject: | Re: Random String Generation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139408@lists.php.net to get a copy of this message | ||
on 13/03/03 5:49 AM, Mike Walth (mike.walth@cinofusion.com) wrote:
> Hello:
>
> What I am trying to do is to create a email verification routine with PHP.
> When people register on the site they will get an email sent to them with a
> link such as
> http://mysite.com/activation.php?ID=ghjghjg367ghjlkj9hjlkjhn0
what you want to do is use the random string as a verifying of an id... so
their email address gets added to the db, with an id and a random value.
your table may look like this:
id
email
stamp
confirm
Then you send an email out with a link. For the fourth email address you
add, it may look like this:
http://site.com/confirm.php?id=4&c=182648
confirm.php grabs the id, checks the confirm code, and if all is well,
resets the confirm code to 1 (true), or "yes", or whatever you choose.
To get the random value, include this function that I just wrote for someone
else in a different thread:
<?
function randNumber($min=1000,$max=99999)
{
// build a seed
list($usec, $sec) = explode(' ', microtime());
$seed = (float) $sec + ((float) $usec * 100000);
// seed random generator
srand($seed);
// return random number
return rand($min,$max);
}
?>
Since the min is 1000, it will never be '1'.
Hope this helps,
Justin