New Zenner
- Join Date:
- Aug 2009
- Posts:
- 40
- Plugin Contributions:
- 0
Trouble getting the value from the zen_draw_pull_down_menu for my contact form
Hi,
I have edited the standard contact form in the tpl_contact_us_defailt.php file by adding extra fields for phone number, subhect and address. These all work perfectly, the user fills in the fields and when submitted, the information is sent to my email.
However, the problem i'm having is with the zen_draw_pull_down_menu which only has the values of 'yes' or 'no'. I have used this to create the form perfectly, but can't figure out how to get the value chosen to be emailed to me with the rest of the contact form!
My code in the tpl_contact_us_defailt.php file looks like this:
<label class="inputLabelContact" for="kitchenbrochure"><?php echo ENTRY_KITCHEN_BROCHURE; ?></label>
<?php echo zen_draw_pull_down_menu('kitchenbrochure' , $YesNoArray , 'id="kitchenbrochure"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
where $YesNoArray contains the values 'yes' and 'no' as the options in the drop down box.
The other file to be edited is the header_php.php file, which currently looks like this:
<?php
/**
* Contact Us Page
*
* @package page
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: header_php.php 3230 2006-03-20 23:21:29Z drbyte $
*/
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$phone = zen_db_prepare_input($_POST['phonenumber']);
$name = zen_db_prepare_input($_POST['contactname']);
$address1 = zen_db_prepare_input($_POST['addressline1']);
$address2 = zen_db_prepare_input($_POST['addressline2']);
$county = zen_db_prepare_input($_POST['addresscounty']);
$postcode = zen_db_prepare_input($_POST['addresspostcode']);
$email_address = zen_db_prepare_input($_POST['email']);
$subject = zen_db_prepare_input($_POST['subject']);
$enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));
$zc_validate_email = zen_validate_email($email_address);
if ($zc_validate_email and !empty($enquiry) and !empty($name) and !empty($subject)) {
// auto complete when logged in
if($_SESSION['customer_id']) {
$sql = "SELECT customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id, customers_telephone
FROM " . TABLE_CUSTOMERS . "
WHERE customers_id = :customersID";
$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
$check_customer = $db->Execute($sql);
$customer_email= $check_customer->fields['customers_email_address'];
$customer_phone= $check_customer->fields['customers_telephone'];
} else {
$customer_phone='Not logged in';
$customer_name= $check_customer->fields['customers_firstname'] . ' ' . $check_customer->fields['customers_lastname'];
}
// use contact us dropdown if defined
if (CONTACT_US_LIST !=''){
$send_to_array=explode("," ,CONTACT_US_LIST);
preg_match('/\<[^>]+\>/', $send_to_array[$_POST['send_to']], $send_email_array);
$send_to_email= eregi_replace (">", "", $send_email_array[0]);
$send_to_email= eregi_replace ("<", "", $send_to_email);
$send_to_name = preg_replace('/\<[^*]*/', '', $send_to_array[$_POST['send_to']]);
} else { //otherwise default to EMAIL_FROM and store name
$send_to_email = EMAIL_FROM;
$send_to_name = STORE_NAME;
}
// Prepare extra-info details
$extra_info = email_collect_extra_info($name, $email_address, $customer_name, $customer_email, $customer_phone, $address1, $address2, $county, $postcode);
// Prepare Text-only portion of message
$text_message = OFFICE_FROM . "\t\t" . $name . "\n" .
OFFICE_PHONE . "\t" . $phone . "\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n" .
OFFICE_ADDRESS . "\t" . $address1 . "\n" .
"\t\t" . $address2 . "\n" .
"\t\t" . $county . "\n" .
"\t\t" . $postcode . "\n\n" .
'------------------------------------------------------' . "\n\n" .
strip_tags($_POST['enquiry']) . "\n\n" .
'------------------------------------------------------' . "\n\n" .
$extra_info['TEXT'];
// Prepare HTML-portion of message
$html_msg['EMAIL_MESSAGE_HTML'] = strip_tags($_POST['enquiry']);
$html_msg['CONTACT_US_OFFICE_FROM'] = OFFICE_FROM . ' ' . $name . '<br />' . OFFICE_PHONE . ' ' . $phone . '<br />' . OFFICE_EMAIL . '(' . $email_address . ')';
$html_msg['EXTRA_INFO'] = $extra_info['HTML'];
// Send message
zen_mail($send_to_name, $send_to_email, $subject, $text_message, $name, $email_address, $html_msg,'contact_us');
zen_redirect(zen_href_link(FILENAME_CONTACT_US, 'action=success'));
} else {
$error = true;
if (empty($name)) {
$messageStack->add('contact', ENTRY_EMAIL_NAME_CHECK_ERROR);
}
if (empty($subject)) {
$messageStack->add('contact', ENTRY_EMAIL_SUBJECT_CHECK_ERROR);
}
if ($zc_validate_email == false) {
$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}
if (empty($phone)) {
$messageStack->add('contact', ENTRY_EMAIL_PHONE_CHECK_ERROR);
}
if (empty($enquiry)) {
$messageStack->add('contact', ENTRY_EMAIL_CONTENT_CHECK_ERROR);
}
}
} // end action==send
// default email and name if customer is logged in
if($_SESSION['customer_id']) {
$sql = "SELECT customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id,customers_telephone
FROM " . TABLE_CUSTOMERS . "
WHERE customers_id = :customersID";
$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
$check_customer = $db->Execute($sql);
$phone= $check_customer->fields['customers_telephone'];
$email= $check_customer->fields['customers_email_address'];
$name= $check_customer->fields['customers_firstname'] . ' ' . $check_customer->fields['customers_lastname'];
}
if (CONTACT_US_LIST !=''){
foreach(explode(",", CONTACT_US_LIST) as $k => $v) {
$send_to_array[] = array('id' => $k, 'text' => preg_replace('/\<[^*]*/', '', $v));
}
}
// include template specific file name defines
$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_CONTACT_US, 'false');
$breadcrumb->add(NAVBAR_TITLE);
?>
Like I said, I've successfully edited these files for the extra input fields but can't figure out what I need to do to get the values from the drop down menu. Any help would be hugely appreciated! Thanks :smile: