PHP hack - 提交表单时打开两个网站
当有人在我们的网站上填写表格并单击“提交”后,他/她将被定向到登陆页面。我想更改该流程,以便在提交时 (1) URL1 作为新窗口打开; (2) 用户从当前表单页面重定向到 URL2。
你能帮忙吗?
当前的代码片段 -
if(! isset($RedirectOnSuccess))
$RedirectOnSuccess = 'oldURL';
我是一名技术新手,因此需要您的帮助将其拼凑在一起。我正在使用 MODx,网页本身使用以下内容调用 php 脚本 - [!FORM_SNIPPET? &RedirectOnSuccess=旧网址 !]
After someone completes a form on our website and clicks on submit s/he is directed to a landing page. I would like to change that flow so that upon submitting (1) URL1 opens as new window; and (2) user is redirected from current form page to URL2.
Can you help?
current code snippet -
if(! isset($RedirectOnSuccess))
$RedirectOnSuccess = 'oldURL';
I'm a tech newbie so need your help in piecing it together. I am using MODx and the web page itself calls the php script with the following -
[!FORM_SNIPPET?
&RedirectOnSuccess=oldURL
!]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
用 JavaScript 来做。 http://www.tizag.com/javascriptT/javascriptredirect.php & http://www.pageresource.com/jscript/jwinopen.htm
do it with javascript. http://www.tizag.com/javascriptT/javascriptredirect.php & http://www.pageresource.com/jscript/jwinopen.htm
这可能取决于弹出窗口的上下文,但您可能会考虑使用侵入性较小且容易拦截广告的内容,而不是使用传统的弹出窗口,例如 lightbox 或页面内其他基于 ajax 的显示工具。您可以通过提交按钮上的单击事件触发灯箱,用它显示您的消息,然后在关闭或确认时提交表单。
避免查看表单结果页面依赖于 JavaScript 的解决方案,因为某些(不常见)用户可能会禁用它。如果按上述方式实现,此类用户将错过您的弹出窗口,但表单仍会通过。
您可以使用 jQuery 来实现此功能,而无需修改 MODx 用于生成表单的 php 代码,而是通过将 javascript 放入 xhtml 标头中,将单击事件附加到表单的提交按钮。例如:
我在这里使用了 ColorBox ,但同样的想法应该适用于其他灯箱替代品。我没有对此进行浏览器测试,因此请务必根据需要进行测试和调整。
It likely depends on the context of your popup, but rather than using a traditional popup you might consider something less invasive and prone to ad-blocking such as a lightbox or other ajax-based display tools within the page. You can trigger the lightbox from a click event on the submit button, display your message with it, and then submit the form on close or confirm.
Avoid solutions where viewing the form result page is dependent on javascript as some (uncommon) users may have it disabled. If it is implemented as above, such users would miss your popup but the form would still go through.
You could use jQuery to implement this without modifying the php code that MODx uses to generate your form, and instead attach a click event to the form's submit button by putting javascript in the xhtml header. For example:
I used ColorBox here, but the same idea should apply to other lightbox alternatives. I didn't browser test this, so be sure to test and adapt as necessary.
考虑到弹出窗口拦截器的问题,您最好的选择是在表单上传时使用 HTML 定位新窗口。
然后使用 JavaScript(可能通过弹出窗口中的
opener.location.href
),您可以将主窗口重定向到另一个 URL。Given problems with popup blockers your best bet is to target a new window with HTML on the form upload.
Then using JavaScript (perhaps via
opener.location.href
in the popup), you can redirect the main window to another URL.