Fale1994 Fale1994 - 1 year ago 189
PHP Question

Generate random activation code in PHP

How to generate random activation code based on current datetime and username in PHP.

The return value should be like this, i.e:


function getActivationCode($username){
$activationCode = "";


return activationCode;

Answer Source

What you are asking for is not random, but:

$string = date('YmdHi') . $username;

Also check out chr function to get a character from a random number (which you can get from mt_rand).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download