If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Aug 2020
    Member #

    how to let visitor change bgcolor for all other visitor

    I find it hard to explain(so i made an image).

    I wish to use URL for a capture the flag game... I can't decide what should be used(jquery, java, iframe, )

    visitor can click a flag and the background would change to the color of that flag.

    All other visitors must be shown the last color clicked even if they refresh the page

    ... that's where my knowledge breaks

    There is plenty of ways to do that for the page you are viewing, but i can't find how to do it from a clicked button to the server for every one else??

    Any direction would help

    issue site question.jpg


  3. #2
    Senior Member sarahswansea's Avatar
    Join Date
    Oct 2015
    Swansea, UK
    Member #
    69 times
    You're going to need your choice of server side language (PHP, Python, Go, Java etc.)

    For something simple like this the easiest solution would be:

    1. when the visitor clicks a flag it sends a POST form request.
    2. the server handling this request then:
    2.1. opens a file on the server e.g. color.txt
    2.2. gets a WRITE lock on the file handle
    2.3. checks the colour is valid e.g. "red" or "blue".
    2.4. writes the colour e.g. "red" to color.txt
    2.5. unlocks the file
    2.6. close the file

    Most file locking functions block until the lock is available, so it's safe if two people try to pick a colour at the same time.

    The process for a user visiting and seeing what the colour is:

    1. a user visits the page
    2. the server handling the request then:
    2.1 (attempts to) opens the file e.g. color.txt on the server
    2.2 gets a READ lock on the file handle
    2.2. reads the colour from the file
    2.3. unlocks the file
    2.4. close the file
    2.5. returns a page with the right colour
    3. if the file was not found, then display the "no user has claimed this URL" page.

    IMPORTANT: if the user is trying to hack your website, they might send a different colour (like green) or something else entirely - like the HTML to redirect you to a spam website. Make sure you check that the user's input is valid!
    Tawesoft <-- hire me here if you need a Go or Python webdev

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT -6. The time now is 07:13 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: