EDIT: I am creating a login and signup for a website. But, I am making it require a activation via email. I want to have them directed to a webpage that changed their "active" status in the database to 1 (boolean) so that they are then permitted to login. All I need now is to be able to change the value in the database
1条回答 默认 最新
- dto5637 2012-05-17 07:03关注
Create a table activations. When user signs up, create a random hash, and store it in this table along with his new user id. Then send an email, containing an url with the hash (for example,
http://example.com/confirmation.php?hash=376728zhdif274thfj36
).In your confirmation.php, you'd take the
$_GET
value, query the database with it, and select the according user id, then run another query with the user id, in which you'd set his activation status.Creating a new hash:
INSERT INTO activations (hash, userid) VALUES ($hash, $userid)
Selecting the userid with the hash:
SELECT userid FROM activations WHERE hash = $_GET['hash']
Updating the activation status with the user id from the query above:
UPDATE users SET active = 1 WHERE userid = $userid
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 matlab不知道怎么改,求解答!!
- ¥15 永磁直线电机的电流环pi调不出来
- ¥15 用stata实现聚类的代码
- ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
- ¥20 docker里部署springboot项目,访问不到扬声器
- ¥15 netty整合springboot之后自动重连失效
- ¥15 悬赏!微信开发者工具报错,求帮改
- ¥20 wireshark抓不到vlan
- ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
- ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持