A Magento 1.9 website worked perfectly with PHP 5.6.40, but the server (which I don't have access to) was upgraded to PHP 7.1 and the custom contact forms stopped working.
It does not give any error, however, the action of the form is not done correctly and redirects to a Login page that I have never seen. It was to send an email and redirect to a pdf.
Does anyone know what can it be?
The module that no longer works:
Controller
<?php
class Empresa_Liga_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
public function postAction()
{
$post = $this->getRequest()->getPost();
if ($post){
try {
$name = $post["name"];
$telefone = $post["telefone"];
$email = $post["email"];
$ddd = substr($telefone, 0, 2);
$to = "[email protected]";
$subject = "Novo Contato";
$body .= "<p>Novo contato pelo formulario: 'A empresa liga pra você'</p>";
$body .= "<p>Nome : " . $name . "</p>";
$body .= "<p>Telefone : " . $telefone . "</p>";
$body .= "<p>Email : " . $email . "</p>";
$from = "[email protected]";
$mail = Mage::getModel('core/email');
$mail->setToName('Your Name');
$mail->setToEmail(array($to,'[email protected]'));
$mail->setBody(utf8_decode($body));
$mail->setSubject($subject);
$mail->setFromEmail($from);
$mail->setType('html');// YOu can use Html or text as Mail format
$mail->setBodyHTML(utf8_decode($body)); // your content or message
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Sua solicitação foi enviada... Em breve entraremos em contato');
$this->_redirect("agradecimento-a-empresa-liga-pra-voce");
return;
} catch (Exception $e) {
Mage::getSingleton('core/session')->addError('Ocorreu um erro, tente novamente mais tarde');
$this->_redirect('*/*/');
return;
}
} else {
$this->_redirect('*/*/');
}
}
}
config.xml:
<?xml version="1.0"?>
<config>
<modules>
<Empresa_Liga>
<version>0.0.1</version>
</Empresa_Liga>
</modules>
<frontend>
<routers>
<brochure>
<use>standard</use>
<args>
<module>Empresa_Liga</module>
<frontName>empresa-liga</frontName>
</args>
</brochure>
</routers>
<layout>
<updates>
<empresa_liga>
<file>brochure.xml</file>
</empresa_liga>
</updates>
</layout>
</frontend>
<global>
<helpers>
<module>
<class>Empresa_Liga_Helper</class>
</module>
</helpers>
</global>
</config>
Data.php
<?php
class Empresa_Liga_Helper_Data extends Mage_Core_Helper_Abstract
{
}