Results 1 to 2 of 2

Thread: not a programmer - pass variable

  1. #1
    Meyer is offline Sugar Community Member
    Join Date
    Oct 2006
    Location
    south africa
    Posts
    646

    Default not a programmer - pass variable

    Hi there

    I am not a programmer so baby steps please.


    When i use the web to lead everythng works great, but i need the reply page" redirect page"

    to say thank you then the details he entered in his Name field,

    an email wil be sent to " the email address he enetered" as soon as possible.

    I read everywhere that this can be done with variables? i have no clue, please help

  2. #2
    manuel2283 is offline Junior Member
    Join Date
    Jul 2009
    Posts
    4

    Default Re: not a programmer - pass variable

    Do you have access to the Database that Sugar is installed on and is it MYSQL?

    My simple suggestion using PHP is create "thankyou.php" redirect people to that page after the lead form has been submitted.

    In the thankyou.php set up something like this.

    Please Note: This is very basic method of doing this so anymore suggestions on how to make this better please do so.

    This grabs the last submission from Sugar with basic variables and email address from the database.

    PHP Code:
    <?//// Grab CRM DATA ////

    $query "



    SELECT
        leads.date_entered
        , leads.first_name
        , leads.last_name
        , leads.phone_mobile
        , leads.primary_address_street
        , leads.primary_address_city
        , leads.primary_address_state
        , leads.lead_source
        , leads.status
     
        , email_addresses.email_address
    FROM
        leads
        LEFT JOIN leads_cstm 
            ON (leads.id = leads_cstm.id_c)
        LEFT JOIN email_addr_bean_rel 
            ON (leads.id = email_addr_bean_rel.bean_id)
        LEFT JOIN email_addresses 
            ON (email_addr_bean_rel.email_address_id = email_addresses.id)
    WHERE (leads.lead_source = 'PUTLEADSOURCEFORFORMHERE'
        AND email_addresses.email_address IS NOT NULL)
    GROUP BY email_addresses.email_address having count(*) >= 1

    ORDER BY leads.date_entered DESC
    LIMIT 0 , 1;


    "

         
    $result mysql_query($query) or die(mysql_error());

    while(
    $row mysql_fetch_array($result)){
        
    $first_name_s $row['first_name'];
    $last_name_s $row['last_name'];
    $mobile_s $row['phone_mobile'];
    $email_s $row['email_address'];
        
    }  
    ?>
        
    }
    Then Send the Email again this is a very basic way of sending emails in PHP I suggest you get this somewhat working then use something like PHP SMTP mailer for a better way of sending email.

    http://blog.taragana.com/index.php/archive/how-to-send-mails-using-smtp-server-in-php/


    PHP Code:
    <?

    // multiple recipients
    $to  $email_s// note the comma

    // subject
    $subject $first_name_a.' '.$last_name_a.' has a message for you.';

    // message
    $message '

    <html>

    <head>

    <head><title>Page title</title></head>


    <style>

    #tablemargin{ margin-top:10px; width:600px; height:579px; }

    body{ margin:0px; padding:0px; font-family:Arial, Helvetica, sans-serif;}



    </style>

    </head>

    <body>

    MESSAGE GOES HERE

    </body>

    </html>


    '
    ;

    // To send HTML mail, the Content-type header must be set

    $headers  'MIME-Version: 1.0' "\r\n";

    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

    // Additional headers
    $headers .= 'To: '.$first_name_s.' '.$last_name_s.'<'.$email_s.'>' "\r\n";
    $headers .= 'From: 'YOUR_FIRST_NAME' 'YOUR_LAST_NAME'<'EMAIL_ADDRESS_YOUWISH_TO_SEND_EMAILS_FROM'>' "\r\n";
    $headers .= 'Cc:' "\r\n";
    $headers .= 'Bcc: copy@test.com' "\r\n";

    // Mail it
    mail($to$subject$message$headers);

    ?>
    Hope this helps to get you started. I have clients requested this and this can get very elaborate as long as you are be able to access the database you can do a lot more in terms of what happens after an user enters a form and what happens after the submission.
    Last edited by manuel2283; 2010-07-15 at 03:04 AM. Reason: Updated info on post

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. pass variable to website using portal
    By mikesolomon in forum Developer Help
    Replies: 2
    Last Post: 2009-07-13, 10:59 AM
  2. In need of Sugar CRM Programmer
    By DataRecoveryCorp in forum Classifieds
    Replies: 4
    Last Post: 2009-04-07, 07:45 AM
  3. In need of Sugar CRM Programmer
    By DataRecoveryCorp in forum Developer Help
    Replies: 3
    Last Post: 2009-04-07, 05:15 AM
  4. Need SugarCRM Programmer
    By Pearl in forum Classifieds
    Replies: 3
    Last Post: 2008-06-06, 12:04 PM
  5. Do I need a programmer\developer?
    By tsidigital in forum Developer Help
    Replies: 0
    Last Post: 2007-04-25, 04:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •