+ 1
html custom link
Let's suppose that I have a with 3 type of users student, teacher and administrator. Every one of them have a different dashboard html page and a profile page that is common for everyone. Now I need to link the dashboard html page to the profile page. Do I need to create 3 different profile html page(with the same content) for every type of user so I can link theirs dashboards? Or can I do it based on the user logged in?
1 Answer
+ 1
Since you tagged with PHP, I'll assume you're using PHP. Since you sound quite new to programming and didn't mention any MVC framework, I'll assume you're not using one.
I would reuse as much as reasonably possible. The profiles for the different types of users probably have a lot in common such as name, possibly a picture, possibly sex/gender. I would use a single PHP script for all types of profiles. I would use if-statements to determine which snippets of user-type-specific code is applied.
Yes, you need to check if the user is signed in since you can't get any profile information otherwise. Yes, use the logged in user to determine the type of profile to show. I wouldn't use the URL like admin_profile.php, teacher_profile.php because you'd have to check if the logged in user matches that type in those PHP scripts anyway and that would needlessly complicate your navigation from other pages.