2

I have contact us page which includes map, form, and some text. the page url is /contacts_page, but when i submit the form it goes to some different url i.e /contacts/index and this new redirect page shows thank you message and contact form. I want to make the url to redirect on same page after submitting with thank you message near the form or in place of form. below is my form.html code. Can anyone check and help me how to fixed it? I dont understand how to display proper html code here

<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<form action="<?php echo Mage::getUrl('contacts/index/post'); ?>" id="contactForm" method="post">
    <div class="fieldset">
        <h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
        <ul class="form-list">
            <li>
                <!-- <label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label> -->
                <div class="input-box">
                    <input name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" placeholder="<?php echo Mage::helper('contacts')->__('Name') ?>" type="text" />
                </div>
            </li>
            <li>
                <!-- <label for="email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label> -->
                <div class="input-box">
                    <input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" placeholder="<?php echo Mage::helper('contacts')->__('Email') ?>" type="text" />
                </div>
            </li>
            <li>
                <!-- <label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label> -->
                <div class="input-box">
                    <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" placeholder="<?php echo Mage::helper('contacts')->__('Telephone') ?>" type="text" />
                </div>
            </li>
            <li class="wide">
                <!-- <label for="comment" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Comment') ?></label> -->
                <div class="input-box">
                    <textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" placeholder="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
                </div>
            </li>
        </ul>
    </div>
    <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>
</form>
<script type="text/javascript">
//<![CDATA[
    var contactForm = new VarienForm('contactForm', true);
//]]>
</script>
  • <div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div> <form action="<?php echo Mage::getUrl('contacts/index/post'); ?>" id="contactForm" method="post"> – needa Jun 29 '16 at 7:26
  • <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> </form> – needa Jun 29 '16 at 7:26
  • this two codes might help for redirection – needa Jun 29 '16 at 7:27
  • I was not able to show it on the post so added here – needa Jun 29 '16 at 7:27
1

You have to rewrite the contact controller action.

Look at Mage_Contacts_IndexController::postAction() (file app/code/core/Mage/Contacts/controllers/IndexController.php).

You will see $this->_redirect('*/*/') that means contacts/index/index.

So, if you want to redirect to another page you have to rewrite the controller's logic and change its redirect destination.

Here is a link of a tutorial on how to override controllers: http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/ .

  • No i want page to redirect on same page itself with thank you message. – needa Jun 29 '16 at 10:12
  • one more question. my emails are going to spam folder how will i fix that? – needa Jun 29 '16 at 10:21
  • That is a server issue, if you do not want to waste your time debuggint it I suggest you to use SMTP Pro module eand configure an external SMTP service. – Phoenix128_RiccardoT Jun 29 '16 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.