May 16, 2008

Changing Background Color In Php - usefull for templating.

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

free web hosting

Changing Background Color In Php - usefull for templating.

sxyloverboy
Tutorial on how to change background color with PHP


I will be descibing to similiar ways that you can change the background color of your website with php and leave it at that till the user changes it again. We are going to do this with CSS. You can either have your cSS info on your page or in a spereate document. The first thing youll have to do is decide if your going for the linked stylesheet or directly on your page. IF you link it you'll need to have this code in you <head> </head> tags.
CODE
<style type="text/css">
<?php include ("style.php") ?>
</style>
This isnt actualy real linking because i dont think you can link css stylesheets that end in .php. Anyways now were going to the read core of this thing. make your style.php file in the same folder where you have your index file or however you call it and put this code in it.
CODE
/* CSS Document */
<?php
$colour=$_GET["bg"];
?>
body {
background:#<?php echo $colour ?>;
}
/* and any other style stuff you want to have */

Now back to the page where you want the background changeing to go on. This is going to be the link that you have
CODE
<a href="?bg=000000">Black</a>
if you want a black background. now you can change 000000 to anyof the RGB color that we use in the web.

The thing is right now the persons gonna go back to haveing white as their background color if they click any link other than that link for the balck background. so what your going to have to do is. Add a "&bg=<?php echo $bg; ?>" to the end of all of your links. that way it always tells it what the color for the background is. and you can also type in background colors into the url itself. so if you type in www.yoursite.com/index?bg=FF0000 your going to have a red background.

Now using this method you can change your whole color scheme of your website with one link and have your visitors choose how they like to have it, just remember to use diffrent variables each time. it could be a for background b for text color c for link colors and so on.

So then guys and gals. Happy Coding. If you have any question feel free to ask me and ill see if i can help. smile.gif

And Merry Xmas and Happy New Year too. Wheee. hahaha

 

 

 


Reply

DreamCore
Nice I have never tryed to use the function "change color" in php. I have only used it in javascript and html. wink.gif

Reply

master_bacarra
QUOTE(sxyloverboy @ Dec 23 2005, 09:13 PM)
The thing is right now the persons gonna go back to haveing white as their background color if they click any link other than that link for the balck background. so what your going to have to do is. Add a "&bg=<?php echo $bg; ?>" to the end of all of your links. that way it always tells it what the color for the background is. and you can also type in background colors into the url itself. so if you type in www.yoursite.com/index?bg=FF0000 your going to have a red background.


but if you're going to use "../index.php?bg=FF0000" in the above statement, anyone can change it, by just typing a different color in hex. that could mess up the entire design of the webpage. what if i don't want the users to change the page's colors directly from the url. instead i want them to choose from different color schemes that is specified in my web page.

 

 

 


Reply

Tyssen
QUOTE(mbacarra @ Jan 12 2006, 03:14 PM)
but if you're going to use "../index.php?bg=FF0000" in the above statement, anyone can change it, by just typing a different color in hex. that could mess up the entire design of the webpage. what if i don't want the users to change the page's colors directly from the  url. instead i want them to choose from different color schemes that is specified in my web page.

In that case you should test your $_GET against an array of permissible values and only execute the script if the value passed from the querystring is in the array.

Reply

Trap FeedBacker
chang background colour
Changing Background Color In Php

How can change a background and text colour. Please help me about this metter.

-reply by Mubashir Malik

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. background color php - 7.09 hr back.
  2. changing php background color - 7.37 hr back.
  3. how to change background time with php - 13.65 hr back.
  4. bg color php - 16.53 hr back.
  5. php set background color - 16.75 hr back.
  6. change background color in php - 23.61 hr back.
  7. how to change background color php - 32.41 hr back.
Similar Topics

Keywords : changing, background, color, php, usefull, templating

  1. Background Image Swap Script
    Change a Background Image based on clock time (13)
  2. Changing Mac Of Ethernet Card
    (2)
    Now you can change Mac address of your ethernet card in windows xp step 1: Double Click on Network
    icons step 2: Select properties step 3: click on configure step 4: On pop up window goto advanced
    tab step 5: now on settings goto locally administered address step 6: Changes the MAC address used
    by this network adapter. The address is a 12-digit hexadecimal number in this range: 0000 0000 0001
    - FEFF FFFF FFFF CAUTION: Make sure no other systems on the network use this address. ....
  3. Changing Default Windows Desktop Theme
    (13)
    How To Pimp Out Your Desktop SECTION 1 As most people know, the default Windows XP desktop is
    pretty dull and boring. The thought of having a field and a crayola taskbar is sickening to me.
    Although some may like it. Today I'm going to show you how to use unsigned visual styles, docks,
    and other gadgets on your desktop. And it's only gonna take a few steps. The first step is to
    downlaod the uxtheme.dll hack. Uxtheme.dll is a file in the System32 folder that will only allow you
    to use visual styles made by Microsoft. By hacking this we will be able to use wh....
  4. Templating System Using Php Includes
    Building a Dynamic site using Includes and flat-files. (13)
    Php based Templating System http://jlhaslip.trap17.com/template/index.php The Source Code
    for the scripts are included (literally) on the different pages on the Demo, including the Contact /
    Email script. The only page not there yet is the Message Script. Maybe tonight I will upload that.
    This one uses a little bit of query-string checking to confirm that the contents of the page are
    actually available (file_exists())and an allowed page content before serving it up. The
    'allowed page content' is done by checking against a flat-file containing an array....
  5. Introduction To Templating
    Templating your website with PHP (1)
    Pre-note Hello and welcome. if your website doesn't use a templating function, you may have
    noticed it's pretty hard to update your website (layout) unless you dig through many files to
    update the images and such. The solution is templates. If you ever got curious and looked into
    phpBB codes or any other template based forum/CMS, you saw the .tpl files they use. I am not at a
    point where i base everything on .tpl (simply because i havent taken the time to see how it all
    works). But i do can tell you that it's the same principle, template your site using an....
  6. Changing A Dynamic Ip
    How to change your dynamic IP. (18)
    In this tutorial I will tell you how to change a dynamic IP if you have Windows XP. First of all go
    to - Start >> Run - and type 'cmd'. A window with a black background and grey text. In
    this window type 'ipconfig' and text should come up saying: IP Address ............. *IP
    HERE* Subnet Mask ................ *SUBNET MASK HERE* Default Gateway .......... *DEFAULT GATEWAY*
    Write this down on a bit of paper on in notepad. You will need them later. Now type
    'ipconfig/release' - this will terminate your internet connection - but don't g....

    1. Looking for changing, background, color, php, usefull, templating

Searching Video's for changing, background, color, php, usefull, templating
advertisement



Changing Background Color In Php - usefull for templating.



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE