Jump to content

Recommended Posts

I was reviewing code from an old practice project for a user reg/login. The activate reg and password reset code first queries if there is a valid hash, then runs the update query. Seems to me it should be just like a registration where you attempt the insert (in this case UPDATE) and catch the failure if any which would eliminate half the code.

 

Interested in anyone's feedback.

Link to comment
https://forums.phpfreaks.com/topic/307198-redundant-query/
Share on other sites

Without understanding the entire workflow, I would say you are correct.

 

The current code (run a select to check for the hash and then run the update) could create a problem with a race condition - if the hash could be changed/deleted. But, there could be legitimate reasons to run a select first and run different branches of logic before proceeding to an update.

Link to comment
https://forums.phpfreaks.com/topic/307198-redundant-query/#findComment-1558033
Share on other sites

I would say the workflow is what you could consider a standard user registration validate email to login process and password reset. You can view the code on My GitHub at the following links

 

https://github.com/benanamen/perfect_app/blob/master/public/activate.php

 

https://github.com/benanamen/perfect_app/blob/master/public/reset.php

Link to comment
https://forums.phpfreaks.com/topic/307198-redundant-query/#findComment-1558035
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.