Here's one that I'm needing help with.

I'm using a survey program to ask my questions what they thought about their experience with my store. An entirely separate program will be doing this. That survey program allows for "tokens" to be created for each surveyor (in this case the customers) and let them take it.

What I want to do is:

1) After checkout is successful, create a token using a random character generator (I've already made it and will provide for the heck of it at the bottom of this post.) and insert that token into the orders database. (In addition, I have to insert it into the survey program database but since both are being run from the same database (different tables), I'll use the $db->Execute command.) Assuming the name survey_token as its column name in Zen's Orders DB.

2) On the template (or define) page for checkout_success, I want to link that customer to that survey. Essentially I would need to call the value I made from step one. (Essentially how checkout_success calls for the order id of the order just created.)

Here is the function I'm using to generate the token for the customer:

PHP Code:
    function random_gen($length)
    {
      
$random"";

      
$char_list "AzByCxDwEvFuGtHsIrJqKpLoMnNmOlPkQjRiShTgUfVeWdXcYbZa";
      
$char_list .= "10293847566574839201";
      
// Add the special characters to $char_list if needed

      
for($i 0$i $length$i++)
      {
        
srand((double)microtime()*1000000);
        
$random .= substr($char_list,rand(1,(strlen($char_list))), 1);
      }
      return 
$random;
    } 
Anyone know where I should start making edits?