doujia1988 2013-07-30 21:37
浏览 60

是否可以使用静音/隐藏GET请求?

I do a GET request as such:

http://www.smurf.com/path/?var=val

This shows up in the URL of the user. I of course see this in nearly every major web-site.

But I was just curious if there is a way around it. It seems kind of ugly and non necessary for the non-programmer to have to look at.

If there is not something current, is there something planned to get rid of the GET request syntax after is has completed?

So that there is just

http://www.foo.com/path/

after the request.

  • 写回答

2条回答 默认 最新

  • dongxia9519 2013-07-30 21:50
    关注

    It seems to be that you're looking to do a POST request. POST requests work, in PHP, identically to GET requests, just use the $_POST superglobal instead of the $_GET superglobal to get POST request parameters.

    In a POST request, the data is sent just like GET (with a few disregardable differences), however it is not visible in the URL, so it fits the description of what you'd like perfectly. Send data like GET, but without user seeing it in the URL.

    Example HTML form:

    <form method="post" action="handler.php">
        <input type="text" name="username"></input>
    </form>
    

    Then if the user submitted this form, you could get the post parameter "username" in PHP just as you would for GET.

    <?php
       $username = $_POST["username"];
    ?>
    

    Then use it to your liking!

    Also, it'd be remiss of me not to mention the intended usages of POST/GET requests. Traditionally, POST requests should be used when data is being sent to the server for storage/usage later such as in a database or online forum. Alternatively GET requests should be used for requesting ("getting") data from the server, and not providing data that will be stored. Using requests in this way is a best practice, but often ignored as it's not enforced by the language but is just a principle.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大