I have a user who registered on my website with some email and password. As soon as he registers we will send a confirmation code to his email and ask him to enter the number to sign up.
Unfortunately there is a possibility that the user may fill the data and may logoff today without entering the confirmation code and he may come back tomorow and login with his registered email. So I would check his email in the database and if he is registered and if his email is under the approval of code sent to his email then I want to redirect him to a page indicating that “a code has been sent to your email respond to your code to sign up” else if he is already registered and there is no pending approvals then redirect him to his profile.
I am not sure the way to do it. I was thinking to use this: if user is under approval then header('location confirmation.php') and if he is approved then header('location profile.php') but I’m not sure if this is the right way to do it. Can headers be used for this purpose? or what is the alternate solution to do it. Please help me with this, thanks.
Yes, you can do this. Please remember to add an
exit;call after all calls toheader()when changing locations, otherwise the entire page is processed and sent to the client. This can be a big security problem, depending on the page content.