[英]How do I Redirect to a 'Thank-You' page after form submission?
I have absolutely no idea how to add a 'thank you page' submission to my clients website.我完全不知道如何向我的客户网站添加“感谢页面”提交。 I am not experienced in coding, only UI etc.
我没有编码经验,只有 UI 等。
Here is a [link][1] to site in question.这是相关网站的 [link][1]。
( EDIT ) Let me elaborate. (编辑)让我详细说明。 I am using Blocs (bootstrap wysiwyg app) and there is a form submit.
我正在使用 Blocs(引导所见即所得应用程序)并且有一个表单提交。 I now need to add a 'thank-you' page redirect for google analytics purposes.
我现在需要为谷歌分析目的添加一个“谢谢”页面重定向。 The code below is what I believe will be able to help:
下面的代码是我相信能够提供帮助的代码:
$(function()
{ var successMsg = "Your message has been sent."; { var successMsg = "您的消息已发送。"; // Message shown on success.
// 成功时显示的消息。 var failMsg = "Sorry it seems that our mail server is not responding, Sorry for the inconvenience!";
var failMsg = "抱歉,我们的邮件服务器似乎没有响应,给您带来不便,我们深表歉意!"; // Message shown on fail.
// 失败时显示的消息。
$("input,textarea").jqBootstrapValidation(
{
preventSubmit: true,
submitSuccess: function($form, event)
{
if(!$form.attr('action')) // Check form doesnt have action attribute
{
event.preventDefault(); // prevent default submit behaviour
var processorFile = "./includes/"+$form.attr('id')+".php";
var formData = {};
$form.find("input, textarea, option:selected").each(function(e) // Loop over form objects build data object
{
var fieldData = $(this).val();
var fieldID = $(this).attr('id');
if($(this).is(':checkbox')) // Handle Checkboxes
{
fieldData = $(this).is(":checked");
}
else if($(this).is(':radio')) // Handle Radios
{
fieldData = $(this).val()+' = '+$(this).is(":checked");
}
else if($(this).is('option:selected')) // Handle Option Selects
{
fieldID = $(this).parent().attr('id');
}
formData[fieldID] = fieldData;
});
First, submit the form and then catch the post.首先,提交表单,然后赶上帖子。 Handle the form and redirect.
处理表单并重定向。
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Handle your form
// redirect
header("Location: thank-you.php");
exit;
}
?>
<form metod="POST" action="<?= $_SERVER['REQUEST_URI']; ?>">
<button type="submit">Send</button>
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.