php - POST 和 GET 方法

标签 php javascript asp.net html

我想将数据从一个网页传输到另一个网页。但我不想使用 <form method="post">标记,因为我的网页中没有表单。只是一些敏感数据需要转移到其他页面。

请回答以下问题:

  1. 有哪些方法可以将数据从一个页面传输到另一页面?
  2. 有哪些方法可以在不使用 <form> 的情况下将数据从一个页面传输到另一页面HTML 中的标签?
  3. 另一个 PHP(或 ASP)页面如何读取另一个页面发送给它的数据?

最佳答案

I don't want to use the <form method="post"> tag because there are no forms in my webpage

这并不是避免使用表单的好理由。您可以添加一个。

What are the ways to transfer data from one page to another?

  1. 通过 URI(在查询字符串中)
  2. 作为请求正文的一部分(POST 请求)
  3. 通过cookie(可以用JS设置)
  4. 通过各种local storage systems

如果数据需要可添加书签,请使用查询字符串。如果在服务器上进行更改(例如添加或编辑数据库条目),请使用 POST 请求(带有表单)。如果数据需要在整个站点中保留,请使用 cookie(最好在使用方法 1 或 2 后通过 HTTP 设置)。将本地存储用于需要离线运行的 Web 应用程序。

What are the ways to transfer data from one page to another without using tag in HTML?

如上所述,但要折扣 post 请求(除非您使用 JavaScript 和 XMLHttpRequest 进行请求)。

How can another PHP (or ASP) page can read the data which was sent to it by another page?

对于本地存储,则不能。所有其他数据都可以通过服务器环境获得(例如,PHP 中的 $_POST$_GET$_COOKIE )。

关于php - POST 和 GET 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7125700/

相关文章:

javascript - AJAX (JQUERY) 的 Server.Map 路径方法

javascript - 使用正则表达式在 css 文件中查找字体

asp.net - 带有集成管道的 IIS 7.5 中的页面 404,使用经典管道很好

asp.net - 如何防止 VB.NET Windows 应用程序和 VB.NET Web 应用程序之间的文件共享发生冲突

php - 如何通过 php 通知我的 iPhone 应用程序名称已添加到数据库中?

php - Google Analytics/Google Ads 添加转化

php - mkdir 的权限将不起作用

javascript - 在 `disconnectedActivitySid` 上使用 `Twilio.TaskRouter.Worker()`

asp.net - 将WebMatrix项目迁移到VS2010

php - DDD - 仅在更改时保留聚合子项