Help with some form code

tidusx18 11 Oct, 2009
Hi,

I have this code...

<?php
$category = "Direct Mail";
$today = date("F j, Y, g:i a");
$message = "
To ensure you receive future notifications, please add
info@ineedapricequote.com to your Safe Sender list.

Hello,

A new lead has been submitted in the $category category. Please be sure to save this email for your reference. To unsubscribe from this category, please reply to this email with \"unsubscribe this category\" in the subject line. 

Lead submitted on $today – ID = $cf_id

------Contact Details------

Name: $_REQUEST[First_name] $_REQUEST[Last_name]
Company name: $_REQUEST[Company_name]
Street address: $_REQUEST[Address]
City: $_REQUEST[City]
State: $_REQUEST[State]
Zip code: $_REQUEST[Zip_code]
Phone: $_REQUEST[Phone]
Other Phone: $_REQUEST[Other_phone]
Fax: $_REQUEST[Fax]
Email: $_REQUEST[Email]
Preferred contact method: $_REQUEST[Preferred_contact_method]

------Mailing Details------
Target audience:  $_REQUEST[type_of_campaign]
Quantity:  $_REQUEST[quantity]
Frequency:  $_REQUEST[frequency]
Geographic target area(s): $_REQUEST[geo_area]
Additional services: $_REQUEST[additional_services_required]
Start in: $_REQUEST[start_when]
Comments: $_REQUEST[comments]

------Ad Details------
Type of ad:  $_REQUEST[type_of_ad]
Ad width:  $_REQUEST[ad_width]
Ad height:  $_REQUEST[ad_height]
Ad paper type:  $_REQUEST[paper_type]
Ad paper type selects:  $_REQUEST[paper_type_selects]
Tabs?  $_REQUEST[tabs]

------ If Magazine, Catalog, etc see below------
Cover paper type: $_REQUEST[cover_paper_type]
Cover paper selects: $_REQUEST[cover_paper_selects]
Number of pages: $_REQUEST[number_of_pages]
Binding type: $_REQUEST[type_of_binding]
";

    $subject = "A new $category lead has been submitted";
    $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers = 'FROM: info@ineedapricequote.com' . "\r\n";

    $db =& JFactory::getDBO();
    $query ="
      SELECT `cb_email`
        FROM `jos_comprofiler`
        WHERE `cb_selectacategory` = ‘$category’ ;
    ";
    $db->setQuery($query);
    $subscribers = $db->loadObjectList();

    foreach ( $subscribers as $subscriber ) {
      mail($subscriber->cb_email, $subject, $message, $headers);
    }
    ?>


The point is to have all the details of the form automatically emailed upon submission to each user in community builder that has selected the forms category from a drop down box in their CB profile page.

Is there anything wrong with the above code because it does not send any emails or give any errors.

Thanks.
GreyHead 12 Oct, 2009
Hi tidusx18,

The only thing I can see with the code is that you have curly quotes in this line
WHERE `cb_selectacategory` = ‘$category’ ;
and you may need straight quotes.

And I assume that you have this in one of the OnSubmit boxes. If you are using the OnSubmit Before box then it will not execute unless Emails are set to 'ON' in the Form General Tab.

The next step would be to set site Error Reporting to Maximum and add some simple debug messages to the code to track the code execution to see where it fails.

Bob

PS In general I'd suggest that you use the JRequest syntax and the Joomla mail function - though I don't see any reason why this code won't work.
tidusx18 13 Oct, 2009
well, it seems that all I had to do was switch the email option on...don't know why because before it was working...and I have the code in the OnSubmit after box.

Thank for the help anyways.

:D
This topic is locked and no more replies can be posted.