简体   繁体   English

表单操作后如何重定向到另一个页面?

[英]How to redirect to another page after form action?

I am using Simple Form (getsimpleform.com) to email the HTML form contents to my email.我正在使用简单表单 (getsimpleform.com) 将 HTML 表单内容通过电子邮件发送到我的电子邮件。 The problem I am facing is that the HTML Form action is handled by getsimpleform so when the user clicks on submit button of the form, they are redirected to https://getsimpleform.com/ but I want them to stay be redirected to another page (ie contact.html).我面临的问题是 HTML 表单操作由getsimpleform处理,因此当用户单击表单的提交按钮时,它们被重定向到https://getsimpleform.com/但我希望它们保持重定向到另一个页面(即contact.html)。

So I want the form action to be performed but at the same time, I want the user to be redirected to another web page.所以我希望执行表单操作,但同时,我希望用户被重定向到另一个网页。

Thanks.谢谢。

Just fill up your action attribute 只需填写您的操作属性即可

<form action="next-page-please-url">
<button>butt</button>
</form>

You can add an action calback on your button, for example : 您可以在按钮上添加动作calback,例如:

in yout HTML 在你的HTML中

<form>
...
<input type="submit" onclick="redirect()">
</form>

and in your javascript : 并在您的JavaScript中:

var redirect = function(){
   document.location.href="contact.html"
}

First of all you need to change the action url of the form to your domain name 首先,您需要将表单的操作URL更改为您的域名

From

action="https://getsimpleform.com/"

To

action="https://YourDomain.com/"

and then on your php or whatever server side language you are using you can redirect eg I will use php example. 然后在您的PHP或您使用的任何服务器端语言,您可以重定向,例如我将使用PHP示例。

header('Location: http://www.YourDomain.com/OtherPage');

Based on their official page recommendation on redirect 基于他们关于重定向的官方页面建议

  <input type='hidden' name='redirect_to' value='https://yourdomain.com/contact.html' />

Try to insert it into the form and see whether it solves your problem. 尝试将其插入表单,看看它是否解决了您的问题。

PS don't forget to change [yourdomain] to your actual domain. PS不要忘记将[yourdomain]更改为您的实际域名。

Unlike the original post, I'm using forms from Ultimate Member but also want to redirect my profile update form after the user presses the UPDATE PROFILE button.与原始帖子不同,我使用的是 Ultimate Member 的表单,但也想在用户按下 UPDATE PROFILE 按钮后重定向我的个人资料更新表单。 The settings in UM have a box to redirect the login and redirect the register but no box to redirect the profile update. UM 中的设置有一个用于重定向登录和重定向注册的框,但没有用于重定向配置文件更新的框。

Assuming the about code works, is this HTML or php?假设 about 代码有效,这是 HTML 还是 php? I think I know how to get html into the webpage....do I dare try to change the PHP file?我想我知道如何将 html 导入网页....我敢尝试更改 PHP 文件吗? If so, were is it?如果是这样,是吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM