About Redirection on Contact Form Questions #3114
-
Preconditions (*)
Steps to reproduce (*)Hello, Dear Team I'm a regular user who knows nothing about PHP writing. The current problem is that I use an extension "Contact Form" installation in website. When I enter all the information and press the send button, the page stays the same and cannot jump to another page "submitted successfully". On my old version 19.4.21, there is no problem. I previously had RC 1 installed, but have now upgraded to RC 2. I thought this patch would fix the problem, but nothing helped. During these 3 days, I took the time to try to solve the limited knowledge by myself and get the information from the web. At the moment, I suspect it might be a "redirect - getRedirectUrl" relationship in your newer version, so this extension can't connect your php script. Also, I don't see any system or exception errors in the logs. I'll link you to a test site if you need to actually see it. This is the phtml file in the contact form. Of course, it connects not just one file, but multiple files. But please read the following in advance. Expected result (*)
<?php
if ($this->getRedirectUrl()) {
?>
<meta http-equiv="refresh" content="0;url=<?php echo $this->getRedirectUrl() ?>">
<script type="text/javascript">
window.location = '<?php echo $this->getRedirectUrl()?>';
</script>
<?php
}
$_uid = $this->getUid();
$_result = $this->getResult();
// get temporary data
$tmpData = Mage::getSingleton('core/session')->getData('webform_result_tmp_' . $this->getWebform()->getId());
if (!empty($tmpData['field']) && is_array($tmpData['field'])) {
foreach ($tmpData['field'] as $field_id => $value) {
$_result->setData('field_' . $field_id, $value);
}
}
if ($this->getWebform()->getIsActive() == VladimirPopov_WebForms_Model_Webforms::STATUS_DISABLED || !$this->isDirectAvailable()) {
echo $this->getNotAvailableMessage();
} else {
if (Mage::registry('show_form_name')) {
?>
<div class="page-title">
<h1><?php echo $this->getWebform()->getName(); ?></h1>
</div>
<?php } ?>
<?php if ($this->isAjax()) { ?>
<div id="webform_<?php echo $_uid ?>_success_text" class="std webforms-success-text"
style="display:none"></div>
<?php } ?>
<?php
if (Mage::registry('show_success')) {
?>
<div class="std webforms-success-text">
<?php echo $this->getSuccessText() ?>
</div>
<?php
}
if (!Mage::registry('show_success') || $this->getData('after_submission_form')) {
?>
<div id="webform_<?php echo $_uid ?>_form">
<?php if ($this->getDescription()) { ?>
<div class="std">
<?php echo $this->getDescription(); ?>
</div>
<?php } ?>
<?php if ($this->isAjax()) { ?>
<iframe id="webform_<?php echo $_uid ?>_iframe"
name="webform_<?php echo $_uid ?>_iframe"
style="width:0;height:0;border:0;position:absolute" role="none"></iframe>
<?php } ?>
<form action="<?php echo $this->getFormAction() ?>" method="post"
name="webform_<?php echo $_uid ?>"
id="webform_<?php echo $_uid ?>" enctype="<?php echo $this->getEnctype() ?>"
class="webforms-<?php echo $this->getWebform()->getCode() ?>"
<?php if ($this->isAjax()) { ?>target="webform_<?php echo $_uid ?>_iframe"<?php } ?>>
<input name="form_key" type="hidden"
value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>"/>
<input type="hidden" name="submitWebform_<?php echo $this->getWebform()->getId() ?>" value="1"/>
<input type="hidden" name="webform_id" value="<?php echo $this->getWebform()->getId() ?>"/>
<?php if ($_result && $_result->getId()) { ?>
<input type="hidden" name="result_id" value="<?php echo $_result->getId() ?>"/>
<?php } ?>
<?php if (is_array($this->getData('hidden'))) {
foreach ($this->getData('hidden') as $key => $value) {
?>
<input type="hidden" name="<?php echo $key ?>" value="<?php echo $value ?>"/>
<?php
}
} ?>
<?php if (count($this->getWebform()->_getHidden())) {
foreach ($this->getWebform()->_getHidden() as $field) {
echo $field->toHtml();
}
} ?>
<?php
foreach ($this->getWebform()->_getFieldsToFieldsets() as $fieldset_id => $fieldset) {
?>
<div id="fieldset_<?php echo $_uid . $fieldset_id ?>"
class="fieldset fieldset-<?php echo $fieldset_id ?> <?php if (!empty($fieldset['css_class'])) echo $fieldset['css_class']; ?>"
role="group" aria-labelledby="legend_<?php echo $_uid . $fieldset_id ?>"
<?php if ($fieldset['logic_visibility'] == VladimirPopov_WebForms_Model_Logic::VISIBILITY_HIDDEN) echo 'style="display:none"'; ?>>
<?php if (!empty($fieldset['name'])) { ?>
<h2 class="legend"
id="legend_<?php echo $_uid . $fieldset_id ?>"><?php echo $fieldset['name'] ?></h2>
<?php } ?>
<ul class="form-list" role="group">
<?php
$k = 0;
$j = 0;
$prev = false;
$fields_count = count($fieldset['fields']);
foreach ($fieldset['fields'] as $field) {
// set temporary value
$field->setData('result', $_result);
$field->setData('uid', $_uid);
$size_class = "fields";
$field_class = "field";
if ($field->getSize() == 'wide') {
$size_class = "wide";
$field_class = "";
}
?>
<?php if ($j % 2 == 0 || $field->getSize() == 'wide' || $prev->getSize() == 'wide') {
$j = 0; ?>
<?php if ($k > 1) { ?></li><?php } ?>
<li <?php if ($size_class == 'wide') { ?>id="field_<?php echo $this->getFieldUid($field->getId()) ?>_row" <?php } ?>
class="<?php echo $size_class ?> <?php if ($size_class == 'wide') { ?>webforms-fields-row-<?php echo $field->getId() ?><?php } ?>"
<?php if ($size_class == 'wide' && $field->getData('logic_visibility') == VladimirPopov_WebForms_Model_Logic::VISIBILITY_HIDDEN) echo 'style="display:none"'; ?>>
<?php } ?>
<?php
$field_css_type = 'type-' . str_replace('/', '-', $field->getType());
?>
<div id="field_<?php echo $this->getFieldUid($field->getId()) ?>"
role="group"
aria-labelledby="label_field<?php echo $this->getFieldUid($field->getId()) ?>"
aria-describedby="comment_field<?php echo $this->getFieldUid($field->getId()) ?>"
class="<?php echo $field_class ?> <?php echo $field->getCssClassContainer() ?> <?php echo $field_css_type ?> webforms-fields-<?php echo $field->getId() ?><?php if ($field->getCode()) { ?> webforms-fields-<?php echo $field->getCode();
} ?>"
<?php if ($field->getData('logic_visibility') == VladimirPopov_WebForms_Model_Logic::VISIBILITY_HIDDEN) echo 'style="display:none"'; ?>>
<?php if ($field->getType() != 'html' && $field->getType() != 'subscribe' && !$field->getHideLabel()) { ?>
<label id="label_field<?php echo $this->getFieldUid($field->getId()) ?>"
for="field<?php echo $this->getFieldUid($field->getId()) ?>"
<?php if ($field->getRequired()) { ?>class="required"<?php } ?>>
<?php if ($field->getRequired()) { ?>
<em>*</em>
<?php } ?>
<?php echo $field->getName() ?>
<?php
$tooltip = $field->getTooltip();
if ($tooltip) {
echo $this->getLayout()->createBlock(
'core/template',
'field' . $this->getFieldUid($field->getId()) . '_tooltip',
array(
'field' => $field,
'tooltip' => $tooltip,
'template' => 'webforms/scripts/tooltip.phtml',
)
)->toHtml();
}
?>
</label>
<?php } ?>
<div class="input-box">
<?php echo $field->toHtml(); ?>
<?php if ($field->getComment()) { ?>
<p id="comment_field<?php echo $this->getFieldUid($field->getId()) ?>"
class="webforms-fields-comment" tabindex="0">
<?php echo nl2br($field->getComment()) ?>
</p>
<?php } ?>
<?php if ($field->getValidationAdvice()) { ?>
<div style="display:none" class="validation-advice"
id="advice-required-entry-field<?php echo $this->getFieldUid($field->getId()) ?>">
<?php echo $field->getValidationAdvice() ?>
</div>
<?php } ?>
</div>
</div>
<?php if ($k == $fields_count - 1) { ?>
</li>
<?php } ?>
<?php
$k++;
$j++;
$prev = $field;
} ?>
</ul>
</div>
<?php
} // foreach 'fields_to_fieldsets'
?>
<?php echo $this->getLayout()->createBlock(
'webforms/gdpr',
'webform_' . $_uid . '_gdpr',
array(
'uid' => $_uid,
'webform' => $this->getWebform()
)
)->toHtml() ?>
<?php if (Mage::getStoreConfig('webforms/honeypot/enable')) {
echo $this->getLayout()->createBlock(
'core/template',
'webform_' . $_uid . '_honeypot',
array(
'webform' => $this->getWebform(),
'template' => 'webforms/scripts/honeypot.phtml',
)
)->toHtml();
} ?>
<div id="submit<?php echo $_uid?>" <?php if($this->getSubmitVisibility() == 'hidden'){?>style="display: none"<?php }?>>
<?php if ($this->getWebform()->useCaptcha()) { ?>
<?php echo $this->getCaptcha()->getHTML() ?>
<?php } ?>
<div class="buttons-set" >
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
<button type="button" class="button"
id="webform_<?php echo $_uid ?>_submit_button"
title="<?php echo $this->__('submit') ?>" name="field[submit]">
<span>
<span><?php echo $this->__($this->getWebform()->getSubmitButtonText()) ?></span>
</span>
</button>
<span class="please-wait" id="webform_<?php echo $_uid ?>_sending_data"
style="display:none;">
<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>"
alt="<?php echo $this->__('Sending...') ?>" title="<?php echo $this->__('Sending...') ?>"
class="v-middle"/><span id="webform_<?php echo $_uid ?>_progress_text"><?php echo $this->__('Sending...') ?></span>
</span>
</div>
</div>
</form>
</div>
<?php echo $this->getLayout()->createBlock(
'core/template',
'webform_' . $_uid . '_submit_script',
array(
'uid' => $_uid,
'webform' => $this->getWebform(),
'ajax' => $this->isAjax(),
'template' => 'webforms/scripts/submit.phtml',
'scroll_to' => $this->getData('scroll_to'),
'after_submission_form' => $this->getData('after_submission_form')
)
)->toHtml();
?>
<?php echo $this->getLayout()->createBlock(
'core/template',
'webform_' . $_uid . '_logic',
array(
'uid' => $_uid,
'webform' => $this->getWebform(),
'template' => 'webforms/scripts/logic.phtml',
)
)->toHtml();
?>
<?php
} // if(show_success)
} // is active Actual result (*)
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 5 replies
-
I tracked down the sample code: https://github.com/kirchbergerknorr/magento1_vladimirpopov_webforms/blob/a82cfe39e47d2e9b86c6a85f5e16c15ae42d4073/app/design/frontend/base/default/template/webforms/sidebar.phtml May be others can help. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply. Yes, you are super capable to find it there. But sadly, since it's a very old version, there is no longer any support and advice. I'm just leaving this question so I can upgrade the new version to use openmage. Otherwise, I need to use the old version to keep using it. May I know your hints? Thank you so much. |
Beta Was this translation helpful? Give feedback.
-
It's probably not difficult to debug and fix your issue, but it's very difficult or impossible without interacting with the code. Do you see any js errors, any PHP errors in the logs: exception.log, system.log, or PHP log? When you click submit, does the controller receive the request? Those are the first couple of steps to get an idea where the problem is. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your kind reply. Mr Ng. Of course, it's easy to fix as your expert. But I'm a normal user with no php knowledge. It is very painful. Since I upgraded from php7.4 to php8.2, it took me more than 3 weeks to test. All my conversion scripts to PHP8.1 are done using phptools.online. Perhaps, I show the steps and results below. 1. data.php file, After the upgrade, the admin page is blank, and the contact form of the web page is also missing. So, I use phptools.online. successfully fixed it. 2. Warning: Trying to access array offset on value of type bool store.php line 26 Then I tried to fix it (I'm not sure if it's correct). After modification, the warning is removed ======================= BEFORE AFTER ======================= I went through the steps above and entered the information into the form, but I only see "Sending.." but not "Redirecting" word show. Backend admin I can see the record on the web form but no email is sent. Currently, I'm finding a problem with displaying https://www.????.com/webforms/index/iframe said : HTTP/2 , 500 Internal Server Error on the browser. I see the /index/iframe page said "The verification code is incorrect, please try again". I compared your form.js files, and the new version modifies something, but I don't think it's causing the problem. Then I inspect the controller (e.g. IndexController.php) as you instructed, and removed the reCaptcha script section and tried redirecting the page without success. I guess google reCaptcha password problem, but after checking it is correct, Next, I tried turning this off this function, but it still gives this warning on the webpage. In the end, I don't think I can do anything here because it took me almost 5 days to fix it. I would like to invite you to help me with this problem. I'll pay for it, but hopefully not too much :) If you accept, I will send you an email with the details of the website. Also, Openmage is a great eCommerce platform. However, there is a lack of alternative extensions on the market. I need to find and download them in forums or other places, but there are not many sources. As our small users, we need to keep the old version of the extension to use, but cannot upgrade php 8.0 above. Hope your great team consider our difficult situation and develop more extensions to replace other old ones. If the dream comes true, I think Openmage will again outperform Magento 2. Thanking You. |
Beta Was this translation helpful? Give feedback.
-
If you're facing the "The verification code is incorrect, please try again" message, then the issue is coming from this method below: Somewhere in the configuration section of the extension you should see an option to disable the Captcha, that will help scope down the problem and we'll figure out why the verification fails afterwards. |
Beta Was this translation helpful? Give feedback.
-
Resolved privately on Discord |
Beta Was this translation helpful? Give feedback.
Resolved privately on Discord