dousha7645 2016-11-19 00:58
浏览 117
已采纳

如何在表单提交上创建新页面?

I'm attempting to create a new page every time a form is submitted. It'll be an order status page- one that'll be updated periodically. Basically, I want the user to see a form confirmation page, and I want it to be permanent link (that they can visit later).

My first thought was using variables in the URL, like so:

http://www.example.org/member.php?id=123

And then calling the id using GET

echo $_GET['id'];

http://www.example.org/member.php would be a template, just waiting for the few details which are specific to the user. Once I have this in place, I could use a simple if statement to check their order status.

For example,

if ($id === "user_id") {
   echo "Your order is: Pending";
}

However, this seems like a bad idea, just for the security aspect of it. If someone else guesses a user ID, they can view their order status. Going off of that, here's my first question.

If the user ID is long enough, is this a secure practice?

Otherwise, what are some other methods of doing this? Creating a new page every time the form is submitted feels like a bad practice- people could spam it, and there's a possibility that someone could exploit this to create malicious pages on the site.

Any suggestions? Most major retail sites have order confirmation pages (think ebay.com)- how do they do it? Also, is my suggested URL format secure?

  • 写回答

3条回答 默认 最新

  • doutou7286 2016-11-19 01:47
    关注

    The most ideal scenario is you force users to login prior to submitting the form then provide them with a list of their past orders of which they can check the status providing the user_id of the order matches the id from the session of the logged in user. Give each order in the list a link like yoursite.com/orders/1 then query for an order with an id of one with a user_id matching the logged in users id to ensure they're the only ones that can view it.

    If you don't want to have to do any of that and just provide a permanent link to the status page I'd save a long randomly generated string against the order and provide it to the user to check in the future, e.g

    yoursite.com/orders/wUk1DhfxMh if you're using a framework with some routing or yoursite.com/orders.php?code=wUk1DhfxMh if you're not.

    Query the database to select the order with the matching code, ensure you prevent MySQL injection and sanitize the $_GET input.

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

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大