运行PHP脚本后重定向 [英] Redirect after running PHP script

查看:107
本文介绍了运行PHP脚本后重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这是处理表单提交并将其输入SQL数据库的脚本。它100%工作。

展开 | 选择 | Wrap | 行号

解决方案

您可以使用JS重定向用户


问候


嘿。


当您尝试标题()时发生了什么?功能?它应该有效。
(尝试启用错误消息,看看到底发生了什么。)


您可以做三件事来重定向用户:

  1. 使用标题发送位置标题功能。 - 这是优选的方法,因为它是最短的方法。向浏览器发送重新定位请求的方式。
  2. 添加< meta> 刷新头。 - 这是紧随其后的一步,只是因为它需要浏览器在实际获取请求之前解析HTML。
  3. 发送JavaScript location.href值。 - 应该避免这种情况,因为在所有情况下都不能指望JavaScript。用户可以关闭JavaScript,有些浏览器(我松散地使用该术语)不支持它。


以某种方式发布了两次

Ok this is the script that handles the form submission and input''s it to the SQL database. It works 100%.

Expand|Select|Wrap|Line Numbers

解决方案

you can use a JS to redirect user

Regards


Hey.

What happened when you tried the header() function? It should have worked.
(Try turning on the error messages to see what really happened.)

You can do three things to redirect a user:

  1. Send a Location header, using the header function. - This is the preferred method, as it is the "shortest" way to send the browser the request to relocate.
  2. Add a <meta> "refresh" header. - This is a close second, only because it requires the browser to parse the HTML before actually getting the request.
  3. Send a JavaScript "location.href" value. - This should be avoided, because JavaScript can not be counted on in all cases. Users can turn off JavaScript, and some browser (and I use that term loosely) don''t support it.


somehow it posted twice


这篇关于运行PHP脚本后重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆