Magento 1.9 Contact Page – Redirect and Add Message

contact-formcontact-uscontrollersmagento-1.9

I use magento 1.9.x version, I add a new contact form in product view page, but after I press Submit button the magento is redirect me to the Contact page how I can stop this redirect and remain in the same page.

I try to put this code in contact controller

            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.'));
           if(Mage::helper('core/http')->getHttpReferer(true)){
            $this->_redirectUrl(Mage::helper('core/http')->getHttpReferer(true)); 
            }
             else{
            $this->_redirect('*/*/');
            }

is work is stay in the same page but I don't see that success message:

"Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us."

How I can add that message too?

Best Answer

Make sure you have put global_messages block on your page.

<?php echo $this->getChildHtml('global_messages') ?>

Also try with below code.

Mage::getSingleton('core/session')->addSuccess( Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
Related Topic