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.

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

报告相同问题?

悬赏问题

  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类