Generate password while sending email?

Any tips and tricks that has to with the ADDT that doesn't fit into one of the other categories
piripacchio
Posts: 37
Joined: 2010-04-28 08:34

Generate password while sending email?

Post by piripacchio » 2016-02-15 16:27

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

User avatar
Fred
Site Admin
Posts: 491
Joined: 2010-02-15 12:10
Location: Armagh, Northern Ireland
Contact:

Re: Generate password while sending email?

Post by Fred » 2016-02-17 14:54

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;*/
?>

piripacchio
Posts: 37
Joined: 2010-04-28 08:34

Re: Generate password while sending email?

Post by piripacchio » 2016-02-17 15:11

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

User avatar
Fred
Site Admin
Posts: 491
Joined: 2010-02-15 12:10
Location: Armagh, Northern Ireland
Contact:

Re: Generate password while sending email?

Post by Fred » 2016-02-18 10:50

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.

Post Reply