helloworld001 Posted December 28, 2014 Share Posted December 28, 2014 Question 1. Say I have a register form where a member registers with their full name but many people can have the same full name. What would be the best way to make the full name appear unique in the url(eg. website.com/member/johnsmith) for each member? Question 2. I am not sure about other CMS but Shopify has this feature where you can change the colors of certain things on the website, in the backend. How is that achieved? I am a little lost on how you should connect css with php. Quote Link to comment https://forums.phpfreaks.com/topic/293419-couple-questions-regarding-displaying-member-name-and-changing-colors/ Share on other sites More sharing options...
hansford Posted December 28, 2014 Share Posted December 28, 2014 What would be the best way to make the full name appear unique in the url(eg. website.com/member/johnsmith) for each member? If you want their name to appear in the url then just show it regardless whether anyone else has that name. I assume they are logged in so they are the only ones viewing it. The session is what will keep track of who they really are as they move about from page to page. The username is their unique identity, not their real name. Quote Link to comment https://forums.phpfreaks.com/topic/293419-couple-questions-regarding-displaying-member-name-and-changing-colors/#findComment-1500871 Share on other sites More sharing options...
hansford Posted December 28, 2014 Share Posted December 28, 2014 (edited) I am not sure about other CMS but Shopify has this feature where you can change the colors of certain things on the website, in the backend. How is that achieved? I can't speak for the way Shopify specifically achieves this, but this can easily be achieved through Ajax calls to the database. Basically, the user selects certain preferences for background colors etc. and these values are then stored in the db. When the user logs in again, these values are extracted from the db and presented as CSS values. When the user wants to change these settings they have some user settings link which allows them to do this. The information is sent to the back-end through Ajax, stored in the database and then Javascript updates whatever elements on the screen. Edited December 28, 2014 by hansford Quote Link to comment https://forums.phpfreaks.com/topic/293419-couple-questions-regarding-displaying-member-name-and-changing-colors/#findComment-1500872 Share on other sites More sharing options...
helloworld001 Posted December 28, 2014 Author Share Posted December 28, 2014 If you want their name to appear in the url then just show it regardless whether anyone else has that name. I assume they are logged in so they are the only ones viewing it. The session is what will keep track of who they really are as they move about from page to page. The username is their unique identity, not their real name. The thing is, I am not using usernames for unique id. The only other unique id I can think of is the register id itself. Come to think of it, I think I know how this can be achieved. I think I have to create 2 columns for the full name. Column 1 will be regular name and column 2 will be regular name + unique number. This way I can input the name with unique number in the url field and use that to fetch rest of the user information from the database. Quote Link to comment https://forums.phpfreaks.com/topic/293419-couple-questions-regarding-displaying-member-name-and-changing-colors/#findComment-1500875 Share on other sites More sharing options...
helloworld001 Posted December 28, 2014 Author Share Posted December 28, 2014 I can't speak for the way Shopify specifically achieves this, but this can easily be achieved through Ajax calls to the database. Basically, the user selects certain preferences for background colors etc. and these values are then stored in the db. When the user logs in again, these values are extracted from the db and presented as CSS values. When the user wants to change these settings they have some user settings link which allows them to do this. The information is sent to the back-end through Ajax, stored in the database and then Javascript updates whatever elements on the screen. This is interesting. I will have to dig more on how to do what you have mentioned. Quote Link to comment https://forums.phpfreaks.com/topic/293419-couple-questions-regarding-displaying-member-name-and-changing-colors/#findComment-1500876 Share on other sites More sharing options...
hansford Posted December 28, 2014 Share Posted December 28, 2014 The thing is, I am not using usernames for unique id. Doesn't matter. When they log in you start a session and create a session variable to hold their name. <?php session_start(); // checked their log-in credentials in the db - they are authentic // grab their data while you're at it $_SESSION['username'] = $row['firstname'] . $row['lastname']; Quote Link to comment https://forums.phpfreaks.com/topic/293419-couple-questions-regarding-displaying-member-name-and-changing-colors/#findComment-1500878 Share on other sites More sharing options...
hansford Posted December 28, 2014 Share Posted December 28, 2014 For the Ajax calls and other JavaScript - I recommend using a library like jQuery for the simple fact that the code has cross-browser support and is routinely updated. No need to check if IE is still an a-hole - who cares. Quote Link to comment https://forums.phpfreaks.com/topic/293419-couple-questions-regarding-displaying-member-name-and-changing-colors/#findComment-1500879 Share on other sites More sharing options...
kicken Posted December 28, 2014 Share Posted December 28, 2014 Question 1. Say I have a register form where a member registers with their full name but many people can have the same full name. What would be the best way to make the full name appear unique in the url(eg. website.com/member/johnsmith) for each member? You need to store their ID in the URL somewhere to make it unique. The name alone is not enough. For example: example.com/member/1234/johnsmith or example.com/member/1234-johnsmith When someone visits the URL you extract the ID and use that to locate the member. Just ignore the name part, it's there only for SEO / Users benefit. Quote Link to comment https://forums.phpfreaks.com/topic/293419-couple-questions-regarding-displaying-member-name-and-changing-colors/#findComment-1500965 Share on other sites More sharing options...
helloworld001 Posted December 28, 2014 Author Share Posted December 28, 2014 Doesn't matter. When they log in you start a session and create a session variable to hold their name. <?php session_start(); // checked their log-in credentials in the db - they are authentic // grab their data while you're at it $_SESSION['username'] = $row['firstname'] . $row['lastname']; Yes you are correct. Before I thought you ment something else. Quote Link to comment https://forums.phpfreaks.com/topic/293419-couple-questions-regarding-displaying-member-name-and-changing-colors/#findComment-1500967 Share on other sites More sharing options...
helloworld001 Posted December 28, 2014 Author Share Posted December 28, 2014 You need to store their ID in the URL somewhere to make it unique. The name alone is not enough. For example: example.com/member/1234/johnsmith or example.com/member/1234-johnsmith When someone visits the URL you extract the ID and use that to locate the member. Just ignore the name part, it's there only for SEO / Users benefit. Yes I came to that concolusion as well, Your idea of using their unique id with the name is very nice. Quote Link to comment https://forums.phpfreaks.com/topic/293419-couple-questions-regarding-displaying-member-name-and-changing-colors/#findComment-1500968 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.