Appnitro Software Forums » MachForm 2

Populate a Text-Field with a Unique value.


  1. RobertHenckel
    Member

    On a Simple Form Being used for membership sign-up's.
    [First Name] [Last Name] <--- All Text
    [UserName]
    [Email Address]
    All text fields - for public entry.
    I would like to have another text field set for Admin View only.
    [Password]

    How can I populate this text field with a "RANDOM String/Number" Automaticaly..Which will then be saved to the database.

    The user will be getting that password in their email upon a sucessfull form completion.

    Posted 3 years ago #
  2. redityo

    Hi,

    You can add a random number to admin field by modify your "post-functions.php. Goto line 147-153 you will find these code :

    if(($element_info[$element_id]['is_private'] == 1) && empty($_SESSION['logged_in'])){
    	if(!empty($element_info[$element_id]['default_value'])){
    		$table_data['element_'.$element_id] = $element_info[$element_id]['default_value'];
    	}
    
    	continue;
    }

    try to replace with this

    if(($element_info[$element_id]['is_private'] == 1) && empty($_SESSION['logged_in'])){
    	if(!empty($element_info[$element_id]['default_value'])){
    		$table_data['element_'.$element_id] = $element_info[$element_id]['default_value'];
    	}
    
    	if ($element_id == 5 && $form_id == 5)
    	{
    		$table_data['element_'.$element_id]  =  (string) rand(1000,2000);
    	}
    	continue;
    }

    in there I assume your admin field element id = 5 with form id = 5 and it will give your random number between 1000 and 2000 for your passoword


    MachForm Support

    Posted 3 years ago #
  3. RobertHenckel
    Member

    Worked Great. I took your sugestion to the next level and modified it to:

    = substr(md5(microtime()), 0, rand(16,16));

    Which increases number of characters to 16 all normal characters.

    Posted 3 years ago #

RSS feed for this topic

Reply