I have a contact from that suppose to send emails to different people as the dropdown option.
The option values are defined in arrays with an array and I am battling to call the array value so the email can go to designated person.
Arrays are defined here:
if((isset($_GET['enquiry']) && $_GET['enquiry']=='Locate a dealer/distributor')||(isset($_POST['enquiry']) && $_POST['enquiry']=='Locate a dealer/distributor')){
$chk_Locate=TRUE;
}
if(isset($_GET['enquiry']) && $_GET['enquiry'] == 'CC'){
$query_recipients = array(array('Complaint', '[email protected]'),
array('Suggestion', '[email protected]'),
array('Compliment', '[email protected]'));
$enquiry = '<input type="hidden" name="enquiry" id="enquiry" value="CC">';
}
else{
$query_recipients = array(array('Locate a dealer/distributor', '[email protected]'),
array('Technical support', '[email protected]'),
array('Back orders', '[email protected]'),
array('Product enquiry', '[email protected]'),
array('Catalog request', '[email protected]'),
array('New customer enquiry', '[email protected]'),
array('Existing customers - logon', '[email protected]'),
array('Existing customers - orders', '[email protected]'),
array('Report web problems', '[email protected]'));
}
Loop
foreach($query_recipients as $key => $val){
if((isset($_POST['enquiry']) && $_POST['enquiry'] == $val[0])||(isset($_GET['enquiry']) && $_GET['enquiry'] == $val[0])){
$selected = $val[0].' : '.$item;
if($val[0]=='Existing customers - logon'||$val[0]=='Technical support'||$val[0]=='Catalog request'||$val[0]=='Product enquiry'||$val[0]=='New customer enquiry'||$val[0]=='Existing customers - orders'||$val[0]=='Catalog request')
The code that calls them is:
$_POST['recipient_email'] = $contact_email.','.$recpt_email;
if(isset($ref_number)){
$_POST['subject'] = 'Examplecompany Group: '.$ref_number.': '.$_POST['enquiry'];
}else{
$_POST['subject'] = 'Examplecompany Group: '.$_POST['enquiry'];
}
$_POST['sender_email'] = $_POST['email'];
$_POST['cc'] = $_POST['email'].', Examplecompany Group <[email protected]>';
$_POST['body'] = '<p>Name: ' . $_POST['name'] . '</p>'
. '<p>Surname: ' . $_POST['surname'] . '</p>'
. '<p>Company: ' . $_POST['company'] . '</p>'
. '<p>Examplecompany Account No.: ' . $_POST['accnr'] . '</p>'
. '<p>Account No. verification: ' . $cust_verify . '</p>'
. '<p>Email: ' . $_POST['email'] . '</p>'
. '<p>Tel/cell: ' . $_POST['tel'] . '</p>'
. $_POST['enquiry'] . ': ' . $_POST['message'];
if(Email::Send($_POST, NULL)){
$message = 'Your feedback has been sent'.$cont_ref;
} else {
$message = 'There was an error sending your feedback';
}
}
This is the line I suppose to use to call them $_POST['recipient_email'] = $contact_email.','.$recpt_email;
for now it works but it calls the last array array('Report web problems', '[email protected]')
irrespective of chosen option.
Please help, if i can find a way to call the array values I believe my form with work according to plan.
There is a line that i dont understand
$enquiry_options .= '<option>'.$val[0].'</option>';
$recpt_email = $val[1];
If the val is set to $Val[1]
the form sends email to the last email address on arrays but if set to $Val[0]
it doesnt.
array('Complaint' => '[email protected]', 'Suggestion' => '[email protected]')
. See php.net/manual/en/language.types.array.php – user113215 Aug 27 '12 at 15:03