
Originally Posted by
DrByte
Based only on what you posted, yes, that appears reasonable.
Coming from you that's good enough for me!!
I was concerned that if I used HTML form code versus the Zen form functions (because I am not fully grasping how to create pulldowns and radioboxes using them..) that there would be issues with the forms.
So here's what I came up with..
My Form:
Code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: tpl_band_signup_default.php,v 1.3 2007/06/07 00:00:00 DrByteZen Exp $
//
?>
<div class="centerColumn" id="customerQuestionnaireDefault">
<h1 id="customerQuestionnaireDefaultHeading"><?php echo HEADING_TITLE; ?></h1>
<?php if ($messageStack->size('customer_questionnaire') > 0) echo $messageStack->output('customer_questionnaire'); ?>
<?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 echo zen_draw_form('customer_questionnaire', zen_href_link(FILENAME_CUSTOMER_QUESTIONNAIRE, 'action=send', 'SSL')); ?>
<div id="customerQuestionnaireContent" class="content">
<p>This form can be used by first time customers and/or customers that aren't sure what to buy. Submit this form and some recommendations will be forwarded to you. This is a courtesy, [[Company Name Goes Here]] will not take any responsibilty if you do not like your purchase. Thanks again for choosing [[Company Name Goes Here]].</p>
<fieldset id="customerQuestionnaire-Info">
<legend> Contact Information </legend>
<div class="alert forward"><?php echo FORM_REQUIRED_INFORMATION; ?></div>
<br class="clearBoth" />
<label class="inputLabel" for="contact1_firstname">First Name:</label>
<?php echo zen_draw_input_field('contact1_firstname', zen_output_string_protected($contact1_firstname), ' size="30" id="contact1_firstname"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label class="inputLabel" for="contact1_lastname">Last Name:</label>
<?php echo zen_draw_input_field('contact1_lastname', zen_output_string_protected($contact1_lastname), ' size="30" id="contact1_lastname"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label class="inputLabel" for="contact1_email">Email:</label>
<?php echo zen_draw_input_field('contact1_email', zen_output_string_protected($contact1_email), ' size="30" id="contact1_email"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label class="inputLabel" for="contact1_phone">Phone:</label>
<?php echo zen_draw_input_field('contact1_phone', zen_output_string_protected($contact1_phone), ' size="30" id="contact1_phone"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label class="inputLabel" for="contact2_phone">Cell Phone:</label>
<?php echo zen_draw_input_field('contact2_phone', zen_output_string_protected($contact2_phone), ' size="30" id="contact2_phone"'); ?>
</fieldset>
<br class="clearBoth" />
<fieldset id="customerQuestionnaire-Contacts">
<legend> Please answer the following questions: </legend>
<label class="inputLabelQuestions" for="question1">What do you want your hair to do?:<?php echo '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<?php echo zen_draw_textarea_field('question1', 30, 4, zen_output_string_protected($question1), 'id="question1"'); ?>
<br class="clearBoth" />
<label class="inputLabelQuestions" for="question2">What state is your natural hair currently in?:<?php echo '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<?php echo zen_draw_textarea_field('question2', 30, 4, zen_output_string_protected($question2), 'id="question2"'); ?>
<br class="clearBoth" />
<label class="inputLabelQuestions" for="question3">What styling options are you interested in?:<?php echo '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<?php echo zen_draw_textarea_field('question3', 30, 4, zen_output_string_protected($question3), 'id="question3"'); ?>
<br class="clearBoth" />
<br />
<label class="inputLabelQuestions" for="question4">Do you prefer virgin hair?:<?php echo '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<select name="question4" id="question4">
<option value="[Select One]">[Select One]</option>
<option value="Yes - I prefer ONLY virgin hair">Yes - I prefer ONLY virgin hair</option>
<option value="No - I do not like virgin hair">No - I do not like virgin hair</option>
<option value="No preference - I like both virgin and premium processed hair">I like both virgin and premium processed hair</option>
<option value="Never used virgin hair before">Never used virgin hair before</option>
</select>
<br class="clearBoth" />
<br />
<label class="inputLabelQuestions" for="question5">Have you had experience with premium hair?:<?php echo '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<select name="question5" id="question5">
<option value="[Select One]">[Select One]</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
<option value="Not sure what premium hair is">Not sure what premium hair is</option>
</select>
<br class="clearBoth" />
<br />
<label class="inputLabelQuestions" for="question6">What daily regime are you familiar with?:<?php echo '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<?php echo zen_draw_textarea_field('question6', 30, 4, zen_output_string_protected($question6), 'id="question6"'); ?>
<br class="clearBoth" />
<label class="inputLabelQuestions" for="question7">What was your favorite hair style to date?:<?php echo '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<?php echo zen_draw_textarea_field('question7', 30, 4, zen_output_string_protected($question7), 'id="question7"'); ?>
<br class="clearBoth" />
<label class="inputLabelQuestions" for="question8">What are your celebrity style inspirations?:<?php echo '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<?php echo zen_draw_textarea_field('question8', 30, 4, zen_output_string_protected($question8), 'id="question8"'); ?>
<br class="clearBoth" />
<label class="inputLabel" for="comments">Other Remarks:</label>
<?php echo zen_draw_textarea_field('comments', 30, 4, zen_output_string_protected($comments), 'id="comments"'); ?>
<br class="clearBoth" />
<?php
// BOF Captcha
if(is_object($captcha)) {
?>
<?php echo $captcha->img(); ?>
<?php echo $captcha->redraw_button(BUTTON_IMAGE_CAPTCHA_REDRAW, BUTTON_IMAGE_CAPTCHA_REDRAW_ALT); ?>
<br class="clearBoth" />
<label class="inputLabel" for="captcha"><?php echo TITLE_CAPTCHA; ?></label>
<?php echo $captcha->input_field('captcha', 'id="captcha"') . ' <span class="alert">' . TEXT_CAPTCHA . '</span>'; ?>
<br class="clearBoth" />
<?php
}
// BOF Captcha
?>
</fieldset>
<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>
<br class="clearBoth" />
</div>
</form>
<?php
}
?>
</div>
My Form Handler:
Code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: header_php.php,v 1.3 2007/06/07 00:00:00 DrByteZen Exp $
//
require(DIR_WS_MODULES . 'require_languages.php');
$breadcrumb->add(NAVBAR_TITLE);
// BOF Captcha
if(CAPTCHA_CONTACT_US != 'false') {
require(DIR_WS_CLASSES . 'captcha.php');
$captcha = new captcha();
}
// EOF Captcha
$error = false;
$contact1_firstname = '';
$contact1_lastname = '';
$contact1_phone = '';
$contact1_email = '';
$contact2_phone = '';
$question1 = '';
$question2 = '';
$question3 = '';
$question4 = '';
$question5 = '';
$question6 = '';
$question7 = '';
$question8 = '';
$comments = '';
$code = '';
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$contact1_firstname = zen_db_prepare_input($_POST['contact1_firstname']);
$contact1_lastname = zen_db_prepare_input($_POST['contact1_lastname']);
$contact1_phone = zen_db_prepare_input($_POST['contact1_phone']);
$contact1_email = zen_db_prepare_input($_POST['contact1_email']);
$contact2_phone = zen_db_prepare_input($_POST['contact2_phone']);
$question1 = zen_db_prepare_input($_POST['question1']);
$question2 = zen_db_prepare_input($_POST['question2']);
$question3 = zen_db_prepare_input($_POST['question3']);
$question4 = zen_db_prepare_input($_POST['question4']);
$question5 = zen_db_prepare_input($_POST['question5']);
$question6 = zen_db_prepare_input($_POST['question6']);
$question7 = zen_db_prepare_input($_POST['question7']);
$question8 = zen_db_prepare_input($_POST['question8']);
$code = zen_db_prepare_input($_POST['code']);
$comments = zen_db_prepare_input(strip_tags($_POST['comments']));
// BOF Error messages
if (!zen_validate_email($contact1_email)) {
$error = true;
$messageStack->add('customer_questionnaire', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}
if (!zen_not_null($contact1_firstname)) {
$error = true;
$messageStack->add('customer_questionnaire', 'Please fill in your First Name');
}
if (!zen_not_null($contact1_lastname)) {
$error = true;
$messageStack->add('customer_questionnaire', 'Please fill in your Last Name');
}
if (!zen_not_null($contact1_phone)) {
$error = true;
$messageStack->add('customer_questionnaire', 'Please fill in your phone number');
}
if (!zen_not_null($question1)) {
$error = true;
$messageStack->add('customer_questionnaire', '<strong>What do you want your hair to do?:</strong> In order for us to assist you, please provide us as much information as possible. If a question does not apply to you, please enter "Not applicable"');
}
if (!zen_not_null($question2)) {
$error = true;
$messageStack->add('customer_questionnaire', '<strong>What state is your natural hair currently in?:</strong> In order for us to assist you, please provide us as much information as possible. If a question does not apply to you, please enter "Not applicable"');
}
if (!zen_not_null($question3)) {
$error = true;
$messageStack->add('customer_questionnaire', '<strong>What styling options are you interested in?:</strong> In order for us to assist you, please provide us as much information as possible. If a question does not apply to you, please enter "Not applicable"');
}
if (!zen_not_null($question6)) {
$error = true;
$messageStack->add('customer_questionnaire', '<strong>What daily regime are you familiar with?:</strong> In order for us to assist you, please provide us as much information as possible. If a question does not apply to you, please enter "Not applicable"');
}
if (!zen_not_null($question7)) {
$error = true;
$messageStack->add('customer_questionnaire', '<strong>What was your favorite hair style to date?:</strong> In order for us to assist you, please provide us as much information as possible. If a question does not apply to you, please enter "Not applicable"');
}
if (!zen_not_null($question8)) {
$error = true;
$messageStack->add('customer_questionnaire', '<strong>What are your celebrity style inspirations?:</strong> In order for us to assist you, please provide us as much information as possible. If a question does not apply to you, please enter "Not applicable"');
}
/*
if (!zen_not_null($code)) {
$error = true;
$messageStack->add('customer_questionnaire', 'Please enter validation code');
}
if (!zen_not_null($contact2_phone)) {
$error = true;
$messageStack->add('customer_questionnaire', 'Please fill in the contact2_phone');
}
if (!zen_not_null($question4)) {
$error = true;
$messageStack->add('customer_questionnaire', 'Please fill in the question4');
}
if (!zen_not_null($question5)) {
$error = true;
$messageStack->add('customer_questionnaire', 'Please fill in the question5');
}
if (!zen_not_null($comments)) {
$error = true;
$messageStack->add('customer_questionnaire', 'Please fill in the comments');
}
*/
// EOF Error messages
//BOF Captcha
if (is_object($captcha) && !$captcha->validateCaptchaCode()) {
$error = true;
$messageStack->add('customer_questionnaire', ERROR_CAPTCHA);
}
//EOF Captcha
if ($error == false) {
// grab some customer info if logged in
if(isset($_SESSION['customer_id'])) {
$check_customer = $db->Execute("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
$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';
}
//assemble the email contents:
$email_text = 'Customer Questionnaire' . "\n" .
'------------------------------------------------------' . "\n" .
'First Name:' . "\t" . $contact1_firstname . "\n" .
'Last Name:' . "\t" . $contact1_lastname . "\n" .
'Email:' . "\t" . $contact1_email . "\n" .
'Phone:' . "\t" . $contact1_phone . "\n" .
'Cell Phone:' . "\t" . $contact2_phone . "\n" .
'------------------------------------------------------' . "\n" .
'What do you want your hair to do?:' . "\n" . $question1 . "\n\n" .
'What state is your natural hair currently in?:' . "\n" . $question2 . "\n\n" .
'What styling options are you interested in?:' . "\n" . $question3 . "\n\n" .
'Do you prefer virgin hair?:' . "\t" . $question4 . "\n\n" .
'Have you had experience with Premium hair?:' . "\t" . $question5 . "\n\n" .
'What daily regime are you familiar with?:' . "\n" . $question6 . "\n\n" .
'What was your favorite hair style to date?:' . "\n" . $question7 . "\n\n" .
'What are your celebrity style inspirations?:' . "\n" . $question8 . "\n\n" .
'Other Remarks:' . "\n" . $comments . "\n\n" .
'------------------------------------------------------' . "\n" .
OFFICE_USE . "\t" . "\n" .
OFFICE_LOGIN_NAME . "\t" . $customer_name . "\n" .
OFFICE_LOGIN_EMAIL . "\t" . $customer_email . "\n" .
OFFICE_IP_ADDRESS . "\t" . $_SERVER['REMOTE_ADDR'] . "\n" .
OFFICE_HOST_ADDRESS . "\t" . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "\n" .
OFFICE_DATE_TIME . "\t" . date("D M j Y G:i:s T") . "\n" .
'------------------------------------------------------' . "\n\n" .
$email_text = zen_output_string_protected($email_text);
$email_html = nl2br("\n" . $email_text);
//send the email
zen_mail(STORE_NAME, SEND_TO_ADDRESS, EMAIL_SUBJECT, $email_text, $contact1_firstname . ' ' . $contact1_lastname, $contact1_email, array('EMAIL_MESSAGE_HTML' => $email_html), 'customer_questionnaire');
zen_redirect(zen_href_link(FILENAME_CUSTOMER_QUESTIONNAIRE, 'action=success'));
} //endif $error=false
} // endif action
// default email and name if customer is logged in
if(isset($_SESSION['customer_id'])) {
$check_customer = $db->Execute("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . $_SESSION['customer_id'] . "'");
if ($contact1_email == '') $contact1_email = $check_customer->fields['customers_email_address'];
if ($contact1_firstname == '') $contact1_firstname = $check_customer->fields['customers_firstname'];
if ($contact1_lastname == '') $contact1_lastname = $check_customer->fields['customers_lastname'];
}
?>
Bookmarks