douju5062 2015-08-31 15:16
浏览 63

在浏览器历史记录中返回时,Uniqid()返回相同的值

I'm using php function uniqid() for creating unique identifier for every order.

<?php $order_id=uniqid(); ?>

And below in form:

<input type="hidden" name="ordercode" value="<?php echo $order_id; ?>">

After submitting form, all data is recorded in mysql database, and user is redirected to payment. It's working ok, but: If I press "back" button in browser and return to order page, input named ordercode contains the old value! This is unwanted because "ordercode" must be unique in database to recognize the order when client will make payment. If I submit the form again, there will be 2 records in database with same ID. I guess this is caused by browser cache. If so, is there any way to force browser to refresh page when going back? Or is there another cause? Any suggestions?

  • 写回答

1条回答 默认 最新

  • dousong4777 2015-08-31 15:21
    关注

    there is simple way to achieve that , you can mark this column ordercode as uniqu from database

    ALTER TABLE table ADD UNIQUE(ordercode);

    评论

报告相同问题?

悬赏问题

  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序