php - F3 路由和动态参数(验证用户注册)
问题描述
我尝试使用 fatfree 框架来完成验证用户注册。
1. user registers account on: website/register
2. I save the user data including a verification key
3. he gets an email sent to the email he provided
4. the email contains the link (http://website/register/verify.php?vkey=$vkey) for verification
5. user clicks the link and gets sent to website/register/verify.php?vkey=91cb65b234b0b5d67df68e0d7f72ed7e
6. on the website I check if isset a verification key, and
7. get the verification key stored in db and compare it with ?vkey=$vkey
8. if they match, all good, reroute
测试结果:
Not Found
HTTP 404 (GET ../register/verify.php?vkey=91cb65b234b0b5d67df68e0d7f72ed7e)
我如何在路由中管理它?
我尝试了什么:
$f3->route('GET /register/verify/@vkey', 'Controller\UserController->registerverified');
$f3->route('GET /register/verify.php?vkey=', 'Controller\UserController->registerverified');
我很困惑,由于参数显然是动态的,如何设置路线?或者有没有其他方法可以验证注册/他来自发送给他的电子邮件中的正确链接?
谢谢!
解决方案
在一些帮助下弄清楚了:
$f3->route('GET /register/verify/@vkey', 'Controller\UserController->registerverified');
然后检查是否 isset
$params['vkey']
推荐阅读
- node.js - Node JS with MongoDB Aggregate with $unwind not working $addFields, $sort, $match 在聚合管道中
- java - 如何根据给定范围从数组中选择一组数字?
- .net-core - DotNet Core 和 Net4.6.1 依赖项
- python-3.x - 如何解决 Chrome 显示“Aw,Snap!”的问题 通过 ChromeDriver 和 Selenium 通过 Python 3 执行测试时的页面
- c - C 是否具有可以测试值是否在预期值的公差范围内的函数,如果不是,我如何创建一个?
- python - 当我有太多但需要全部数据时,如何预处理我的数据?
- amp-html - amp-img srcset 的问题
- c++ - 删除使数据处于“不良状态”的默认构造函数的模式?
- python - 用 numpy 将具有不同维度的大型矩阵相乘
- php - cURL 正在 Ubuntu 上自行卸载