douyalin2258 2011-07-28 05:05
浏览 328
已采纳

如何防止两个用户注册相同的用户名?

I am working on a Zend Framework application with PHP. I have a form for sign up.

Now when a user sign up and got a user name that is available and the process of sign up is still not completed. And selected user name is not still saved in database. So at the same time no another one get same user name.

so please help how i can prevent that no another user can assign the same user name at same time.

for example a user does not exists in database i.e. mannecheema27

so that it should be free to register. But the process of registering takes some time. Perhaps a user receives a phone call or may be some other reason, then I want that the selected user name to be reserved on sever for that time period until user save his/her registration or click on cancel registration button , so that whenever at same time another user check availability of user name i.e. mannecheema27 then in database it does not exists but it must be stored at sever so that no other user gets the same name.

  • 写回答

1条回答 默认 最新

  • duanjia8215 2011-07-28 05:14
    关注

    either accept it that the final registration will fail since another user chose this name, or when checking that the username is not registered do a 'reservation entry' in the user database that will then be later used (or at some point in time unreserved).

    The second one is more coding, but really the only way to go. If it is an application where you expect a lot of user creations, accept it that the final registration may fail.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao