简体   繁体   English

将用户重定向到另一个页面-PHP

[英]Redirect user to another page - PHP

I created a page, where user can register himself/herself. 我创建了一个页面,用户可以在此注册自己。 At the time of first login of user, user will redirect to add-profile page, where user can create his/her profile, after creation of profile user will redirect to another page which is account page where he/she can check his/her profile. 首次登录用户时,用户将重定向到添加个人资料页面,用户可以在其中创建他/她的个人资料,创建个人资料后,用户将重定向到另一个页面,该页面是他/她可以检查他/她的帐户页面。轮廓。

And my problem starts here, when the same user login his/her account second time, he/she will again redirect to add-profile page. 我的问题从这里开始,当同一用户第二次登录他/她的帐户时,他/她将再次重定向到添加配置文件页面。 But here i want to redirect user to account page, because user completed his/her profile page. 但是在这里我想将用户重定向到帐户页面,因为用户完成了他/她的个人资料页面。

Does anyone know, how to achieve this? 有谁知道,如何实现这一目标? I mean what logic will be apply here. 我的意思是什么逻辑将在这里适用。

There could be multiple possible solutions and it all depends on your project requirement. 可能有多种解决方案,并且都取决于您的项目要求。

A possible solution is, you can create a flag/status column in your table which says about the basic completion of user profile. 一个可能的解决方案是,您可以在表中创建一个标志/状态列,该列说明用户配置文件的基本完成情况。

Means you can set its value to true when user has submitted some basic details that is mandatory for your project. 意味着当用户提交了一些对项目必不可少的基本详细信息时,可以将其值设置为true。 In that case you can redirect user to some other page else redirect to add profile page. 在这种情况下,您可以将用户重定向到其他页面,或者将用户重定向到添加配置文件页面。

The best way to achieve this is to add a new field and if the user completed the profile page set the field value as 1 . 实现此目的的最佳方法是添加一个新字段,如果用户完成了配置文件页面,则将字段值设置为1 After logging in you check the field and if it set to 1 redirect it to the account page. 登录后,检查该字段,如果该字段设置为1 ,则将其重定向到帐户页面。 That is it 这就对了

The solution is simple, you just have to create an extra column named as user_profile_complete in your user database table, which takes boolean values (ie True/False). 解决方案很简单,您只需要在用户数据库表中创建一个名为user_profile_complete的额外列即可,该列采用布尔值(即True / False)。 True value means user completed it's profile while False means not completed yet it's profile.By default , you have to set it's value as Flase . 值表示用户已完成其概要文件,而值表示尚未完成其概要文件。默认情况下,您必须将其值设置为Flase

So after user registeration, you know to redirect user to fill profile details page. 因此,在用户注册后,您知道将用户重定向到填写个人资料详细信息页面。 But, when after user login, first you have to check whether user completed it's profile or not by checking the user_profile_complete column (Note:- you can query to get user_profile_complete field value at login time or you can create separate query).If user_profile_complete is False , you have to redirect user to fill profile details page, otherwise redirect to it profile page. 但是,在用户登录后,首先必须通过检查user_profile_complete列来检查用户是否完成了它的配置文件(注意:-您可以在登录时查询以获得user_profile_complete字段值,也可以创建单独的查询)。如果user_profile_completeFalse ,您必须将用户重定向到填写个人资料详细信息页面,否则,将用户重定向到该个人资料页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM