Jump to content

Couple questions regarding displaying member name and changing colors


helloworld001

Recommended Posts

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.

 

 

Link to comment
Share on other sites

 

 

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.

Link to comment
Share on other sites

 

 

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 by hansford
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

 

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'];
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

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.

Link to comment
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.