dongliao3450 2013-05-25 16:43
浏览 56
已采纳

在页面上获取请求删除POST信息

I have a page called test_photo.php, which people get directed to from a form after doing a POST request

<form id="search_photos" action="test_photo.php" method="post">
    <select name="photographer" id="photographer">
        <option selected="selected" value="x">Any Photographer</option>
    </select>

    <--Removed for clarity sake -->

    <input name="Submit" value="Search Now &gt;" id="Submit" type="submit">
</form>

on the page that we post to (test_photo.php) we have pagination to help break up the huge amount of data that gets displayed. This is handled by a GET request the url may look something like http://foobar.com/xpath/test_photo.php?page=0.

The problem is that whenever someone perform a get request on the page the POST data disappears. Does anyone know any way in which we can solve this.

  • 写回答

4条回答 默认 最新

  • duanmei1694 2013-05-25 17:03
    关注

    Okey, trying to rule out the obvious here.

    You are mixing GET and POST in a way that is incorrect. You should only address POST if you have a form with values you don't want exposed and those values are no longer needed after submitting (like logging in). Here you have values that you carry on to the next page etc.

    This will never work because if you post a form, the POST-values are only available right after you submitted the form. If you try to do a clean refresh (not reposting the form), you will see that the values are gone.

    What you should do it posting the form as POST and then building a query of GET-parameters.

    Like

    page.php?page=1&photographer=1&location=3
    

    This is a correct way to address filters. Just look at how Google is storing the current search-query (google.com?q=your search). The rule is "values needed across different pages"? Just GET. This will also make it possible for people to bookmark searches or send them to other people with all the filters applied.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘