我们是磁铁和面临问题问题的新手我填写表格后我联系我们页面不工作,然后提交然后出现错误'无法提交您的请求。请稍后再试“我该怎么办?请帮助我。链接 http://under555.com/contact_us
答案 0 :(得分:1)
联系表单提交给此控制器,
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();
}
$mailTemplate = Mage::getModel('core/email_template');
/* @var $mailTemplate Mage_Core_Model_Email_Template */
$mailTemplate->setDesignConfig(array('area' => 'frontend'))
->setReplyTo($post['email'])
->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
null,
array('data' => $postObject)
);
if (!$mailTemplate->getSentSuccess()) {
throw new Exception();
}
$translate->setTranslateInline(true);
Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
$this->_redirect('*/*/');
return;
} 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;
}
您可以在此处输入错误消息。所以
去检查这个文件,以便找到问题所在。主要是由hideit
输入字段引起的此错误。您可以在同一个文件中启用此字段的验证
if (!Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
$error = true;
}
如果你发现这个只是将其注释掉或用下面的一个替换,
if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
$error = true;
}
那就是它。如果您有任何疑问,请在此处发表评论。
答案 1 :(得分:0)
可能解决问题的第一件事就是改变以下功能
app/code/core/Mage/Core/Model/Email/Template.php copy to
app/code/local/Mage/Core/Model/Email/Template.php
public function setReplyTo($email)
{
$this->getMail()->addHeader('Reply-To', $email);
return $this;
}
到
public function setReplyTo($email)
{
$this->getMail()->setReplyTo($email);
return $this;
}
<强> Or 强>
app/design/frontend/YOUR_THEME/template/contacts/form.phtml
Add this after the <form> tag:
<input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />