dongtangu8615 2014-02-04 11:49
浏览 63
已采纳

PHP存储输入变量替代

I am making a payment process/checkout system where a user is required to go through 3 separate pages (chooseplan.php -> payment-details.php -> confirm.php) before the checkout information is sent to paypal.

Already in the first page (chooseplan.php) a user is required to pick a pricing plan, and that is being posted to payment-details.php in a form, such as:

<input type='hidden' name='plan' value='enterprise'>

From the payment-details.php I am retrieving it by $_POST to do validation and later drop it in an input tag again, just to be able to post it in a form (again) to the last page: confirm.php.

I was wondering if there is another way of storing this variable, rather than constantly reposting it, validating and creating another input field on every page it goes through. I would prefer not seeing the variable in the url (GET). Also, without javascript or session.

  • 写回答

2条回答 默认 最新

  • douye2020 2014-02-04 14:26
    关注

    Sessions are the best way to go, but if you want to increase the security of the whole transaction, you can generate a token based on the data already selected, then keep that token on the session or a database.

    Then you have two options, one is sending the token with the new form, including the hidden fields and on the way back, compare the token with the one you already have, if it's different, then something happened and you abort; if the same, you generate again the token with the hidden data and compare it to the token saved, if it's not the same, you abort. The second option is only sending the data, without the token and saving one step.

    Of course all the steps to generate a secure token have to be taken.

    On each page you will generate a new token based on the new information.

    I hope I explained myself clearly enough with all the back and forth.

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

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献