So I decided to put together a summary post of all the things posted in this thread to help save others the troubles I ran into when trying to implement this solution.. I am using the posts by adem.i, dw08gm, and shartlesville as my references for the Contact Us form as it is a combination of their posts that got me on the right path with this solution. WhitePhoenix graciously provided the code for the Create an Account form..
I am only correcting code and path errors I found in some of these posts, and making sure that the code is inside forum code tags (makes the code much EASIER to read)... Otherwise all credit for the content of this post goes to the original contributors.
Also let me be clear here.. I am NOT taking anything away from dlg_ie who posted this ingenious solution in the first place. His original post did spur some great follow-up minor "improvements" IMHO.. The posts used as reference with these "improvements" aren't dramatically different from dlg_ie's original post. They do however include two things that I felt were important "improvements" as follows:
- Faking a success message for the bots
- Comments so that these changes are easy to spot in the event of upgrades/other enhancements
Maybe someone should put this all together as a proper add-on.. and yes I am throwing this out to the universe/community at large because I personally have no plans to throw my hat into that ring.. Doesn't mean it's not a good idea for SOMEONE ELSE to do it though..
Contact Us Page
in /includes/templates/YOUR_TEMPLATE/templates/tpl_contact_us_default.php find:
Code:
<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>
<?php echo zen_draw_input_field('email', ($email_address), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
directly under it put this:
Code:
<!-- NOSPAM -->
<input style="visibility:hidden; display:none;" name="leaveblank" type="text">
<br class="clearBoth" />
<!-- NO SPAM -->
in includes/modules/pages/contact_us/header.php make the following changes:
Highlight this (around line 14):
Code:
$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$name = zen_db_prepare_input($_POST['contactname']);
$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)) {
Replace that entire block with this:
Code:
$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$name = zen_db_prepare_input($_POST['contactname']);
$email_address = zen_db_prepare_input($_POST['email']);
$subject = zen_db_prepare_input($_POST['subject']);
// NO SPAM
$leaveblank = zen_db_prepare_input($_POST["leaveblank"]);
// NO SPAM
$enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));
//edited for NO SPAM
$zc_validate_email = zen_validate_email($email_address);
if ($zc_validate_email and !empty($enquiry) and !empty($name) and empty($leaveblank)) {
Then find (around line 93):
Code:
if (empty($enquiry)) {
$messageStack->add('contact', ENTRY_EMAIL_CONTENT_CHECK_ERROR);
}
Directly under it add:
Code:
//NO SPAM
if (!empty($leaveblank)) {
zen_redirect(zen_href_link(FILENAME_TIME_OUT, 'action=success'));
}
//NO SPAM
Create New Account
in includes/modules/YOUR_TEMPLATE/create_account.php make the following changes:
(This is the ONLY file you will make this edit to. Please note in WhitePhoenix's original post it was suggested to also edit includes/modules/create_account.php.Please note that this edit should ONLY be done as an override. Therefore DO NOT add these edits toincludes/modules/create_account.php)
around line 79 find:
Code:
$password = zen_db_prepare_input($_POST['password']);
Directly under it add:
Code:
// BOF CSS_ANTI_SPAM
$leaveblank = zen_db_prepare_input($_POST["leaveblank"]);
// EOF CSS_ANTI_SPAM
around line 245 find:
Code:
if (strlen($password) < ENTRY_PASSWORD_MIN_LENGTH) {
$error = true;
$messageStack->add('create_account', ENTRY_PASSWORD_ERROR);
} elseif ($password != $confirmation) {
$error = true;
$messageStack->add('create_account', ENTRY_PASSWORD_ERROR_NOT_MATCHING);
}
Directly under it add:
Code:
// BOF CSS_ANTI_SPAM
if (!empty($leaveblank)) {
zen_redirect(zen_href_link(FILENAME_DEFAULT));
}
// EOF CSS_ANTI_SPAM
in includes/templates/YOUR_TEMPLATE/templates/tpl_modules_create_account.php
around line 159 find:
Code:
<fieldset>
<legend><?php echo TABLE_HEADING_LOGIN_DETAILS; ?></legend>
<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL_ADDRESS; ?></label>
<?php echo zen_draw_input_field('email_address', '', zen_set_field_length(TABLE_CUSTOMERS, 'customers_email_address', '40') . ' id="email-address"') . (zen_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="alert">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
Directly under it add:
Code:
<!-- NOSPAM -->
<input style="visibility:hidden; display:none;" name="leaveblank" type="text">
<br class="clearBoth" />
<!-- NO SPAM -->
around line 184 find:
Code:
<label class="inputLabel" for="password-confirm"><?php echo ENTRY_PASSWORD_CONFIRMATION; ?></label>
<?php echo zen_draw_password_field('confirmation', '', zen_set_field_length(TABLE_CUSTOMERS, 'customers_password', '20') . ' id="password-confirm"') . (zen_not_null(ENTRY_PASSWORD_CONFIRMATION_TEXT) ? '<span class="alert">' . ENTRY_PASSWORD_CONFIRMATION_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
</fieldset>
Directly under it add:
Code:
<?php
// BOF insert for anti-spam-login
?>
<input style="visibility:hidden; display:none;" name="leaveblank" type="text">
<?php
// EOF insert for anti-spam-login
?>
Test your forms normally to make sure you DO get the proper e-mails back. Then using firefox, disable the inline CSS styles filling out all the lines including the one that should be blank. When you hit send, you should be redirected to the session timed out page. If you get blank pages or the email goes through when it shouldn't, verify all the changes for missing punctuation and check the CACHE file for errors.
If you are using the "Report a Cheaper Price" mod, shartlesville's original post will help you with modifying this form:
http://www.zen-cart.com/showthread.p...34#post1078934

Originally Posted by
shartlesville
For the Report A Cheaper Price mod in
includes/templates/template_default/tpl_report_a_price_default.php find (about line 74):
Code:
<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>
<?php echo zen_draw_input_field('email', ($error ? $_POST['email'] : $email), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
directly under it add:
Code:
<!-- NOSPAM -->
<input style="visibility:hidden; display:none;" name="leaveblank" type="text">
<br class="clearBoth" />
<!-- NO SPAM -->
Then in
includes/modules/pages/report_a_price/header.php find (about line 35):
Code:
$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$name = zen_db_prepare_input($_POST['contactname']);
$email_address = zen_db_prepare_input($_POST['email']);
$other_store = zen_db_prepare_input(strip_tags($_POST['other_store']));
$other_store_location = zen_db_prepare_input(strip_tags($_POST['other_store_location']));
$other_price = zen_db_prepare_input(strip_tags($_POST['other_price']));
$zc_validate_email = zen_validate_email($email_address);
if ($zc_validate_email and !empty($other_store) and !empty($other_store_location) and !empty($other_price) and !empty($name)) {
Replace with
Code:
$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$name = zen_db_prepare_input($_POST['contactname']);
$email_address = zen_db_prepare_input($_POST['email']);
// NO SPAM
$leaveblank = zen_db_prepare_input($_POST['leaveblank']);
// NO SPAM
$other_store = zen_db_prepare_input(strip_tags($_POST['other_store']));
$other_store_location = zen_db_prepare_input(strip_tags($_POST['other_store_location']));
$other_price = zen_db_prepare_input(strip_tags($_POST['other_price']));
$zc_validate_email = zen_validate_email($email_address);
if ($zc_validate_email and !empty($other_store) and !empty($other_store_location) and !empty($other_price) and !empty($name) and empty($leaveblank)) {
Test the form normally to make sure you DO get mail from customers. Then using firefox, disable the inline CSS styles filling out all the lines including the one that should be blank. When you hit send, you should be redirected to the session timed out page. If you get blank pages or the email goes through when it shouldn't, verify all the changes for missing punctuation and check the CACHE file for errors.
If you get a blank page after this, check for syntax errors - I had an extra } on line 128 next to
Code:
} // end action==send
When I deleted it, it worked.