“Unable to submit your request. Please try again later”.
Contact Us Form - Error: Unable to submit your request, please try again later
If you look at the code /app/code/core/Mage/Contacts/controllers/IndexController.php
public function postAction()
{
$post = $this->getRequest()->getPost();
if ( $post ) {
$translate = Mage::getSingleton('core/translate');
/* @var $translate Mage_Core_Model_Translate */
$translate->setTranslateInline(false);
try {
$postObject = new Varien_Object();
$postObject->setData($post);
$error = false;
if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {
$error = true;
}
if (!Zend_Validate::is(trim($post['comment']) , 'NotEmpty')) {
$error = true;
}
if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
$error = true;
}
if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
$error = true;
}
if ($error) {
throw new Exception();
}
(...snip...)
} catch (Exception $e) {
$translate->setTranslateInline(true);
Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
$this->_redirect('*/*/');
return;
}
The Contact Us form requires the Name, Comment, Email not be empty or NULL. We do expect the “hideit” field to (a) exist and (b) be empty/NULL. The “hideit” field is new in 1.4 and is designed to help prevent spam. Automated bots would complete this field and this is how we can detect bots. It’s best to implement a Captcha system as well on your Contact Us page to further improve your spam protection.
If any of the above checks fail, the function throws an exception and we get the “Unable to submit your request. Please, try again later” message. The message would be more descriptive if it read “Unable to submit your request, please verify all required fields have been completed”. You can change the message in the locale translation file if you want. This will also future proof you against updates.
The best thing to do is examine the code on your site. Those site’s I’ve looked at have the following:
<div class="button-set">
<p class="required">* Required Fields</p>
<button type="submit" class="form-button"><span>Submit</span></button>
</div>
The correct code should be:
<div class="buttons-set">
<p class="required">* Required Fields</p>
<input type="text" style="display: none ! important;" value="" id="hideit" name="hideit">
<button class="button" title="Submit" type="submit"><span><span>Submit</span></span></button>
</div>
Either something went wrong with the upgrade and the underlying files didn’t get upgraded, or you’re overriding the files within your theme directory.
The Contact Us form is generated by /app/design/frontend/base/default/template/contacts/form.phtml. The code from a working 1.4.0.1 environment looks like this:
<div class="buttons-set">
<p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
<input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
<button type="submit" title="<?php echo Mage::helper('contacts')->__('Submit') ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
</div>
Remember to backup any files you edit, before editing
You can choose either to edit the file directly or better yet, replace it with the correct 1.4.0.1 file.
No comments:
Post a Comment