We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21246
    • 55 Posts
    Skills - MODX / PHP developer
    anticipated start time: TODAY 04/09/2010 (another dev left me hanging)
    anticipated job duration : 1 Hour
    budget constraints : $40 - Plus I will donate $20 to Modx project wink or you donate your work to the Modx project here and I donate 100% to it.
    payment terms : Paypal or similar on sucessfull testing of code

    scope of work :

    Refer a Friend Lead Generator

    What is it? A simple form that a existing customer, with an account number, uses to invite his friends (up to 5 with the 1st required ) to visit a web page estimate form on the same site that retreives the $account as a paramater of the url and stores it along with the form submission.

    The first form for client submission and the snippet function to store submission in custom table built and working. See snippet code below.

    What I need is a function that loops through each ref#email (only if we have ref#fname and ref#lname + ref#email ) and generates the mail. SMTP from the server is enabled so mail() will work. I have a canned message but would like to take the value from a chunk with placeholders in it.

    The form fields should be checked / further sanitized.

    Here is the simple eform2db snippet that is working.

    <code>
    <?php
    function referal2db(&$fields)
    {
    global $modx;
    //init the array
    $dbTable = array();
    $dbTable[’firstname’] = $modx->db->escape($fields[’firstname’]); // submitter
    $dbTable[’lastname’] = $modx->db->escape($fields[’lastname’]);
    $dbTable[’account’] = $modx->db->escape($fields[’account’]);
    $dbTable[’email’] = $modx->db->escape($fields[’email’]);
    $dbTable[’submittedOn’] = date( ’YmdHis’, strtotime( $fields[postdate] ) );
    $dbTable[’ref1fname’] = $modx->db->escape($fields[’ref1fname’]); // recipient 1 - req
    $dbTable[’ref1lname’] = $modx->db->escape($fields[’ref1lname’]);
    $dbTable[’ref1email’] = $modx->db->escape($fields[’ref1email’]);
    $dbTable[’ref2fname’] = $modx->db->escape($fields[’ref2fname’]); // recipient 2
    $dbTable[’ref2lname’] = $modx->db->escape($fields[’ref2lname’]);
    $dbTable[’ref2email’] = $modx->db->escape($fields[’ref2email’]);
    $dbTable[’ref3fname’] = $modx->db->escape($fields[’ref3fname’]); // recipient 3
    $dbTable[’ref3lname’] = $modx->db->escape($fields[’ref3lname’]);
    $dbTable[’ref3email’] = $modx->db->escape($fields[’ref3email’]);
    $dbTable[’ref4fname’] = $modx->db->escape($fields[’ref4fname’]); // recipient 4
    $dbTable[’ref4lname’] = $modx->db->escape($fields[’ref4lname’]);
    $dbTable[’ref4email’] = $modx->db->escape($fields[’ref4email’]);
    $dbTable[’ref5fname’] = $modx->db->escape($fields[’ref5fname’]); // recipient 5
    $dbTable[’ref5lname’] = $modx->db->escape($fields[’ref5lname’]);
    $dbTable[’ref5email’] = $modx->db->escape($fields[’ref5email’]);
    $dbTable[’remote_addr’]=$_SERVER[’REMOTE_ADDR’];
    $dbTable[’user_agent’]=$_SERVER[’HTTP_USER_AGENT’];
    //insert into the db
    $dbQuery = $modx->db->insert($dbTable, ’referrals’ );
    return true;
    }

    return ’’;
    ?>
    </code>




    IP ownership constraints - Will donate function back to community.

    If you are interested in this reply to post with your details and whether you will be donating your time or not.
      • 21246
      • 55 Posts
      CLOSED - I wrote it my self after reading my scope it became clear what to do. Sorry.

      Created a multi-dimensional array from the $fields array. Looped through each dimension and processed an the email using mail();

      I still plan on donating. I will post the snippet after adding some good validation and error handling.

      Thanks.