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条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器