We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Generating a Random Key in PHP?; How to do it.
Topic Started: Jun 6 2005, 09:00 PM (256 Views)
Dennis
Member
[ *  *  *  *  *  *  * ]
Specifically one similar to the random key generated by IPB for validating members. Is there any easy way to do something similar? It should be database-driven, so it can be used for multiple purposes, kind of like how IPB's is used for Validating, New Passwords, etc.

Thanks. :)
Offline Profile Quote Post Goto Top
 
Rory
i;m a mess
[ *  *  *  *  *  *  * ]
Not entirely random, but you could make an md5 hash of various fields that a user has submitted, say, username, password and e-mail address or something.
Offline Profile Quote Post Goto Top
 
Sani
Member Avatar
Member
[ *  *  *  *  * ]
It dowsnt need to be database driven, If all you need to do is present the numbers/text to the user..
Code:
 
function randomise() {
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
  $i = 0;
  while ($i <= 7) {
        $num = rand() % 33;
        $tmp = substr($salt, $num, 1);
        $srand= $srand. $tmp;
        $i++;
  }
  return $srand;
}


To use it..

Code:
 
$random = randomise();
echo $random;
//Form stuff here..

if ($randomcheck == $random){
//Register} else {die("Die, you dumb bot!");


$randomcheck would be the form field where the user enters the rendom stuff found in $random.

Hope I was coherent.. :D

*Sani just woke up, kinda groggy.. :lol:
Online Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply