I have the exact same problem as Salixia allthough I hope you solved it somehow? I'm making a subscriptions form and d'be happy to post it here later. I have three radiobuttons for three alternatives.
What is the correct validation code in the php header for radiobuttons? Also saw Dr Bytes response in another thread about the customer being able to reference the type of order at a later time and it being visible in customers pages in admin. But even the simpler version where I get the answer of what button was marked in the e.mail would be great to start with.
My code looks like this in tpi_default file:
<?php
/**
* Page Template
*
* Loaded automatically by index.php?main_page=contact_us.<br />
* Displays contact us page form.
*
* @package templateSystem
* @copyright Copyright 2003-2005 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: tpl_contact_us_default.php 3230 2006-03-20 23:21:29Z drbyte $
*/
?>
<div class="centerColumn" id="subscriptions">
<?php echo zen_draw_form('subscriptions', zen_href_link('subscriptions', 'action=send')); ?>
<?php
if (isset($_GET['action']) && ($_GET['action'] == 'success')) {
?>
<div class="mainContent success"><?php echo TEXT_SUCCESS; ?></div>
<div class="buttonRow"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div>
<?php
} else {
?>
<?php if (DEFINE_SUBSCRIPTIONS_STATUS == '1') { ?>
<div id="subscriptionsContent" class="content">
<?php
/**
* require html_define for the contact_us page
*/
require($define_page);
?>
</div>
<?php } ?>
<?php if ($messageStack->size('contact') > 0) echo $messageStack->output('contact'); ?>
<fieldset id="subscriptionsForm">
<legend><?php echo HEADING_TITLE; ?></legend>
<div class="alert forward"><?php echo FORM_REQUIRED_INFORMATION; ?></div>
<br class="clearBoth" />
<?php
// show dropdown if set
if (CONTACT_US_LIST !=''){
?>
<label class="inputLabel" for="send-to"><?php echo SEND_TO_TEXT; ?></label>
<?php echo zen_draw_pull_down_menu('send_to', $send_to_array, 'id=\"send-to\"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<?php
}
?>
<p class="StoryContentColor"><br />
<label for="yes1">Alt.1<?php echo SUBS_ON_GOING; ?></label>
<input type="radio" id="yes1" name="radiobutton" value="ongoing" checked="checked" />
<br />
</p> <p class="StoryContentColor"> <br />
<label for="yes2">Alt.2<?php echo SUBS_SIX_MONTHS; ?></label>
<input type="radio" id="yes2" name="radiobutton" value="sixmonths" />
<p class="StoryContentColor"> <br />
<label for="yes3">Alt.3<?php echo SUBS_FULL_YEAR; ?></label>
<input type="radio" id="yes3" name="radiobutton" value="fullyear" />
<label class="inputLabel" for="contact_name"><?php echo ENTRY_NAME; ?></label>
<?php echo zen_draw_input_field('contact_name', $name, ' size="40" id="contact_name"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label class="inputLabel" for="contact_company_name"><?php echo ENTRY_COMPANY_NAME; ?></label>
<?php echo zen_draw_input_field('company_name', ($error ? $_POST['company_name'] : $company_name), ' size="40" id="company_name"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label class="inputLabel" for="delivery_address"><?php echo ENTRY_DELIVERY_ADDRESS; ?></label>
<?php echo zen_draw_textarea_field('delivery_address', ($error ? $_POST['delivery_address'] : $delivery_address), ' size="30" id="delivery_address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label class="inputLabel" for="delivery_address_other"><?php echo ENTRY_DELIVERY_ADDRESS_OTHER_THAN_OWN; ?></label>
<?php echo zen_draw_textarea_field('delivery_address_other', '30', '3', '', 'id="delivery_address_other"'); ?>
<br class="clearBoth" />
<label class="inputLabel" for="phone_number"><?php echo ENTRY_PHONE; ?></label>
<?php echo zen_draw_input_field('phone_number', ($error ? $_POST['phone_number'] : $phone_number), ' size="40" id="phone_number"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label class="inputLabel" for="email_address"><?php echo ENTRY_EMAIL; ?></label>
<?php echo zen_draw_input_field('email_address', ($error ? $_POST['email_address'] : $email_address), ' size="40" id="email_address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label class="inputLabel" for="dob"><?php echo ENTRY_DOB; ?></label>
<?php echo zen_draw_input_field('dob', ($error ? $_POST['dob'] : $dob), ' size="20" id="dob"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label class="inputLabel" for="comments"><?php echo ENTRY_COMMENTS; ?></label>
<?php echo zen_draw_textarea_field('comments', '30', '7', '', 'id="comments"'); ?>
</fieldset>
<input type="submit">
<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_SEND_ALT); ?></div>
<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div>
<?php
}
?>
<br class="clearBoth" />
</form>
</div>
Everything shows except the radiobutton aswers which displays like this in my e-mail:
Från: Anna Lindstrl
Email: [email protected]
Subs_On_Going:
Subs_Six_Months:
Subs_Full_Year:
Name:
Company_Name:
Yieojom Ab
Address:
Tykurtart 45 76589 Olsma
Address:
Phone: 075839201
DOB: 760706-5679
Comments:
No Yes next to any of the alternatives..
And the header.php file 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')) {
$name = zen_db_prepare_input($_POST['contact_name']);
$email_address = zen_db_prepare_input($_POST['email_address']);
$zc_validate_email = zen_validate_email($email_address);
if ($zc_validate_email and !empty($name)) {
// 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
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_name= $check_customer->fields['customers_firstname'] . ' ' . $check_customer->fields['customers_lastname'];
} else {
$customer_email='Not logged in';
$customer_name='Not logged in';
}
// 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);
// Prepare Text-only portion of message
$text_message = OFFICE_FROM . "\t" . $name . "\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n" .
"Subs_On_Going:\n" . $selected_radio =($_POST['subs_on_going']) . "\n" .
"Subs_Six_Months:\n" .$selected_radio =($_POST['subs_six_months']) . "\n" .
"Subs_Full_Year:\n" . $selected_radio =($_POST['subs_full_year']) . "\n" .
"Name:\n" . strip_tags($_POST['customer_name']) . "\n" .
"Company_Name:\n" . strip_tags($_POST['company_name']) . "\n" .
"Address:\n" . strip_tags($_POST['delivery_address']) . "\n" .
"Address:\n" . strip_tags($_POST['delivery_address_other_than_own']) . "\n" .
'------------------------------------------------------' . "\n\n" .
"Phone:\t\t" . strip_tags($_POST['phone_number']) . "\n" .
"DOB:\t\t\t" . strip_tags($_POST['dob']) . "\n" .
"Comments:\n" . strip_tags($_POST['comments']) . "\n" .
'------------------------------------------------------' . "\n\n" .
$extra_info['TEXT'];
$html_msg['EMAIL_MESSAGE_HTML'] = nl2br($text_message);
// 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_EMAIL . '(' . $email_address . ')';
$html_msg['EXTRA_INFO'] = $extra_info['HTML'];
// Send message
zen_mail($send_to_name, $send_to_email, 'Body Mind Elements shop: Subscriptions', $text_message, $name, $email_address, $html_msg,'subscriptions');
zen_redirect(zen_href_link('subscriptions', 'action=success'));
} else {
$error = true;
if (empty($name)) {
$messageStack->add('contact', ENTRY_EMAIL_NAME_CHECK_ERROR);
}
if ($zc_validate_email == false) {
$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_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
FROM " . TABLE_CUSTOMERS . "
WHERE customers_id = :customersID";
$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
$check_customer = $db->Execute($sql);
$email_address = $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/', 'define_subscriptions.php', 'false');
$breadcrumb->add(NAVBAR_TITLE);
?>
WHAT AM I MISSING PLEASE!? I've tried working this out on my own for a while now.. would be most happy to get some input!
Dr Byte..? Anyone?
Thanks in advance!:wacko: