I suspect there’s an easy way to send all the contents of a form to an email address, natively with CodeIgnitor scripting, but I thought I’d first try some PHP techniques I’ve used in the past with the Email library. Well, it’s not working. Here’s the entire controller:
// this first part handles the Lead_Request checkbox array from the form
if (isset($_POST['Lead_Request']) && is_array($_POST['Lead_Request']))
{
$_POST['Lead_Request'] = implode(", ", $_POST['Lead_Request']);
}
$this->db->insert('leads', $_POST);
// insert works without everything below
$Lead_Date = $_POST('Lead_Date');
$First_Name = $_POST['First_Name'];
$Last_Name = $_POST['Last_Name'];
$Company = $_POST['Company'];
$Title = $_POST['Title'];
$Phone = $_POST['Phone'];
$Email = $_POST['Email'];
$Opt_in = $_POST['Opt_in'];
$AcctPackage = $_POST['AcctPackage'];
$Lead_Received = $_POST['Lead_Received'];
$Lead_Source = $_POST['Lead_Source'];
$Promotion_Code = $_POST['Promotion_Code'];
$Lead_Request = $_POST['Lead_Request'];
$Situation = $_POST['Situation'];
$Comments = $_POST['Comments'];
$body = 'The following user has submitted a lead from the Internal Lead Form:\n\nName: $First_Name $Last_Name\nCompany: $Company\nPhone Number: $Phone\nEmail: $Email\nOpt In: $Opt_in\nAccounting Package: $AcctPackage\nLead Received: $Lead_Received\nLead Source: $Lead_Source\nPromotion Code: $Promotion_Code\nCurrent Situation: $Situation\nLead Request: $Lead_Request\n\nComments: $Comments\n';
$this->load->library('email');
$this->email->from('to@xyz.com', 'Todd S');
$this->email->to('mickey@abc.com');
$this->email->subject('Internal Lead Submission');
$this->email->message($body);
$this->email->send();
echo $this->email->print_debugger();
}
Unfortunately, it doesn’t spit out any error, just a blank page. The db Insert works fine up until I set all the $_POST variables for the email. I suspect one solution might to be implode all the $_POST variables into a $body array without setting them individually, as I’ve done. I’m just not sure exactly how to do that in CodeIgnitor shorthand.
