简体   繁体   中英

PHP: How to allow users to change background color of their profile?

I have made a social networking site. One of the feature I would like to add is to allow users to change the background image of their profile.I have written javascript for it, but once I change background image of one user, all users background change to that image. What should I do to avoid this.

Javascript Code for switching background

Change background option in Settings page

You should load the background image dynamically for each user.

This is just a streamline of what I think you should do:

  1. Create a field in the DB for every user to hold the path for the bg image
  2. Once logged in check if they have that setted on their profile
  3. Change it dynamically using js

Step 1: you have to create a field in database to hold the url or location of background which user sets.

Step 2: make sure that location of that background having one to one relation with userid or with user . So this mean you have to add column in user table or make a new table with relation to userid

And each time when user profile loaded first check or make a JavaScript or php or server side code to set background dynamically. You can also use ajax.

Above steps are simple workflow path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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