Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Changing Background Color In Php, usefull for templating.
sxyloverboy
post Dec 23 2005, 01:13 PM
Post #1


Super Member
*********

Group: Members
Posts: 302
Joined: 17-June 05
From: Frankfurt, Germany
Member No.: 8,358



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
Go to the top of the page
 
+Quote Post
DreamCore
post Dec 23 2005, 04:31 PM
Post #2


Premium Member
********

Group: Members
Posts: 199
Joined: 29-September 05
Member No.: 12,363



Nice I have never tryed to use the function "change color" in php. I have only used it in javascript and html. wink.gif
Go to the top of the page
 
+Quote Post
master_bacarra
post Jan 12 2006, 05:14 AM
Post #3


I'm back... well, sort of.
*********

Group: [HOSTED]
Posts: 697
Joined: 26-December 05
From: somewhere in the middle of nowhere
Member No.: 16,226
Spam Patrol



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.
Go to the top of the page
 
+Quote Post
Tyssen
post Jan 12 2006, 12:36 PM
Post #4



***********

Group: Members
Posts: 1,161
Joined: 9-May 05
From: Brisbane, QLD
Member No.: 6,818



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.
Go to the top of the page
 
+Quote Post
iGuest
post Apr 24 2008, 11:25 AM
Post #5


Hail Caesar!
*********************

Group: Members
Posts: 5,876
Joined: 21-September 07
Member No.: 50,369



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
Go to the top of the page
 
+Quote Post
iGuest
post Jul 4 2008, 11:21 AM
Post #6


Hail Caesar!
*********************

Group: Members
Posts: 5,876
Joined: 21-September 07
Member No.: 50,369



where to but a link
Changing Background Color In Php

It seems as if the link is to insert the picture but want to know where to write the link code?

-reply by brenda
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Changing A Dynamic Ip(18)
  2. Templating System Using Php Includes(13)
  3. Changing Mac Of Ethernet Card(2)
  4. Background Image Swap Script(15)


 



- Lo-Fi Version Time is now: 13th October 2008 - 12:36 AM