一次在PHP中下载liks? [英] One time download liks in php?

查看:57
本文介绍了一次在PHP中下载liks?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在php中创建一个一次性下载链接,因为我的客户希望在其网站上出售公交车票.我是一个初学者/从未真正编写过自己的php,并且我试图为该票创建一个一次性下载链接.问题是,php也动态创建了凭证ae,并且链接中存储了一个变量,否则我只能使用cms的内置功能.但是,我想创建一个指向该页面的一次性链接,以便通过重定向将人们重定向到该页面.

I am trying to create a one time download link in php as my client would like to sell bus trip tickets on their website. I am a begginer/ never really wrote my own php and I am trying to create a one time download link for the tickets. The issue is that the vouchers ae created dynamically by php too and a variable is stored in the link, otherwise I could just use the builtin function of my cms. However, I want to create one time link to a page redirecting people to the page with the redirect.

如果有人可以概述创建一次链接的过程,那将是一件非常有意义的事情,并且如果有人可以提供一些很好的示例代码.

If someone could outline the process of creating one time links that would be greatly apreciated, and if some could provide some example code that would be great.

谢谢你, 托马斯

推荐答案

大纲如下:

  • 生成唯一ID-可以使用 uniqid
  • 将其插入数据库
  • 将链接发送给以某种方式使用该ID的用户,例如/download/{id}
  • 当用户转到链接时,请在您的数据库中注册已使用的链接
  • Generate a unique ID - uniqid can be used
  • Insert that into your database
  • Send a link to the user that uses that ID in some way, like /download/{id}
  • When the user goes to the link, register in your database that it has been used

然后确保您的下载脚本检查ID是否曾经使用过.

And then make sure that your download script checks whether the id has been used before.

这篇关于一次在PHP中下载liks?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆