Page 1 of 1

Generate password while sending email?

Posted: 2016-02-15 16:27
by piripacchio
Hi all,
I'm still on top of ADDT (until I find something else that allow me to do the same thinks faster) and now I need to create a form contaning mainly 3 fields:
- name
- email
- password (hidden field) (see below)

The form should insert a record in a db and the password should be generated automatically. Is there a way to do this in an insert transaction?

If I remember correctly there is a "generate forgot password page" in the server behaviours, but is there something similar to create password on-the-fly while inserting a record?

TIA

Re: Generate password while sending email?

Posted: 2016-02-17 14:54
by Fred
It's actually quite simple to do.
Use this function and add the result into the hidden password field.

Code: Select all

<?php function getRandomString($length) {
    $validCharacters = "abcdefghijklmnopqrstuxyvwzABCDEFGHIJKLMNOPQRSTUXYVWZ123456789"; // add or remove characters you want to be used in the rendom string
    $validCharNumber = strlen($validCharacters);
 
    $result = "";
 
    for ($i = 0; $i < $length; $i++) {
        $index = mt_rand(0, $validCharNumber - 1);
        $result .= $validCharacters[$index];
    }
 
    return $result;
}

/* Include in file 
 Then call as follows

$random_str = getRandomString(100); // set the length of the random string inside the brackets ()
echo $random_str;*/
?>

Re: Generate password while sending email?

Posted: 2016-02-17 15:11
by piripacchio
Hi Fred, thanks for this reply.
It's really usefull.
Thanks very much for your INVALUABLE help.
You are the only "help" I have for ADDT. ;).
I yet have to find a replacement for ADDT but nothing came close to it...
It's the only tool that allow to create complex thinks with few clicks...
Shame (again) on adobe.
Tony

Re: Generate password while sending email?

Posted: 2016-02-18 10:50
by Fred
You welcome Tony.
Same here. Doing a lot of front-end coding manually but for general back-end stuff Interakt is still doing the job.
Backends tends to stay the same, List of things that needs updating. Don't think its going to change any time soon.