handiling color parameters comming through the link

Hi, I need to know how I can make a page handle parameters it receives in the link to determine its background and text colors. It should be able to handle a situation where only one of the two parameters is sent. That is all I need and I am not looking for something more complicated than that. Is that doable in html or java script and what is a simple way for me to do it.<br />
<br />
So these frour links would open the same page but with different background and text colors (page does not exist):<br />
<br />
<!-- m --><a class="postlink" href="http://www.xyxyxy.com/page.htm?bgcolor_var=F7EBE7&fgcolor_var=000000">http://www.xyxyxy.com/page.htm?bgcolor_ ... var=000000</a><!-- m --><br />
<br />
<!-- m --><a class="postlink" href="http://www.xyxyxy.com/page.htm?fgcolor_var=B7A756&bgcolor_var=C8ECC0">http://www.xyxyxy.com/page.htm?fgcolor_ ... var=C8ECC0</a><!-- m --><br />
<br />
<!-- m --><a class="postlink" href="http://www.xyxyxy.com/page.htm?bgcolor_var=64C8EC">http://www.xyxyxy.com/page.htm?bgcolor_var=64C8EC</a><!-- m --><br />
<br />
<!-- m --><a class="postlink" href="http://www.xyxyxy.com/page.htm?fgcolor_var=9B7A116">http://www.xyxyxy.com/page.htm?fgcolor_var=9B7A116</a><!-- m --><br />
<br />
Thanks<br />
Sam<!--content-->Yes, it is doable in javascript, but if you have a server that supports PHP, that would be a _far_ better option. Got PHP?<!--content-->YES, the site is hosted on a server that supports PHP 4.1.1<br />
<br />
Sam<!--content-->Before we go further, I should make sure....Are these pages on your own domain? They need to be in order to do it.<!--content-->YES they are and thanks a lot :)<br />
<br />
Sam<!--content-->Ok, give me a bit to work this out, ok?<!--content-->Hi, to make sure I gave you a good answer ... this page will be hosted on a server that supports PHP on a domain that I control. On the other hand, the link of this page (that also includes the color parameters) may be used from anywhere. Am I still OK ?<br />
<br />
Thanks<br />
Sam<!--content-->Yes you are....<!--content-->As promised...<br />
<br />
<?PHP<br />
<br />
$background = "FFFFFF"; # Set default background color, if none was set.<br />
$foreground = "000000"; # Set default font color, if none was set.<br />
<br />
#Don't edit below this line<br />
<br />
$bgcolor = $background;<br />
$fgcolor = $foreground;<br />
<br />
if ($QUERY_STRING != "")<br />
{<br />
<br />
$query = $QUERY_STRING;<br />
<br />
list($one,$two)= split ("&", $query);<br />
<br />
list($placeone,$bgcolor)= split ("=", $one);<br />
<br />
if ($placeone == "bgcolor_var")<br />
{<br />
list($placeone2,$fgcolor)= split ("=", $two);<br />
if ($placeone2 != "fgcolor_var")<br />
$fgcolor = $foreground;<br />
}<br />
<br />
if ($placeone == "fgcolor_var")<br />
{<br />
$fgcolor = $bgcolor;<br />
$bgcolor = $background;<br />
}<br />
<br />
}<br />
<br />
echo ("<style type=\"text/css\">\n");<br />
echo ("body {\n");<br />
echo ("background-color: #$bgcolor;\n");<br />
echo ("color: #$fgcolor;\n");<br />
echo ("}\n");<br />
echo ("</style>");<br />
?>Insert that into your <head><br />
<br />
and here is the link code that you need...<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"your.php?bgcolor_var=F7EBE7&fgcolor_var=FF0000">specify both</a><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"your.php?bgcolor_var=F7EBE7">specify background</a><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"your.php?fgcolor_var=FF0000">specify foreground</a><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"your.php">use default</a><!--content-->Thank you sooooooooo much <br />
<br />
Works very well exept in one case and that is when the fgcolor is positioned in the link before the bgcolor. In this case the the back ground color is always set to white. Like in this case<br />
page.php?fgcolor_var=119876&bgcolor_var=333333<br />
<br />
All other cases work fine. My question is wether the code was designed assuming that the bgcolor is the first parameter or order should not matter and this is a small bug in the code. I will look into it if you say its a bug. Sure if that is how its designed then that is good enough. I mainly want to know for my self as I go head and analyze the first php code I see in my life :)<br />
<br />
Thanks you very much again<br />
Sam<!--content-->It was designed that way. I should have mentioned it. Sorry.<br />
<br />
Origianlly posted by Salam<br />
I mainly want to know for my self as I go head and analyze the first php code I see in my life :)Glad to see you are going to try to figure out the logic behind it. If you need any help, let me know.<!--content-->Hi, actually I am sure that I can change the code so that order is not important ... its like normal programming. My question here is on the style code<br />
<br />
echo ("<style type=\"text/css\">\n");<br />
echo ("body {\n");<br />
echo ("background-color: #$bgcolor;\n");<br />
echo ("color: #$fgcolor;\n");<br />
echo ("}\n");<br />
echo ("</style>");<br />
<br />
Seems to me (I sure can be wrong) that the style code makes the page assume the text on the page is English letters ... do you know if this is right ?<br />
<br />
Thanks again<br />
Sam<!--content-->I'm not sure I understand what you mean. All that the style code is doing is setting the background and font color...<!--content-->Yes, you are right, that code has nothing to do with the language. The contents of the page is Arabic and with the file becomming a PHP file when I load the page I see the Arabic text scrambled and for it to become readable every time after I load the page in the browser I need to select "view" then "encoding" then "windows(Arabic) from the browser menue. Sure this is my problem and will work on it.<br />
<br />
Last two questions and I do not want to be more anoying than that. You really got me on my feet with PHP :)<br />
<br />
1)<br />
If you know the answer, can I make FrontPage handle PHP files. Now its not and I have to use NotePad instead. FrontPage 2000 help does not say anything about PHP<br />
<br />
2)<br />
Do you know of a good on line reference for PHP ? I used to program in Java and C and I think that from this point I can manage doing simple PHP stuff if I have an online reference.<br />
<br />
Thanks a lot<br />
Sam<!--content-->1) Do you mean make FrontPage your default PHP editor?<br />
<br />
2) I use <!-- m --><a class="postlink" href="http://www.php.net">http://www.php.net</a><!-- m -->. It's great.<!--content-->Hi, thanks for the PHP site. on the other hand, YES I like to be able to make FrontPage be able to edit PHP files. I am a FrontPage user. Question if this is doable or not.<br />
<br />
Thanks,<br />
Sam<!--content-->I don't know if you can make FrontPage edit PHP...I don't think so, sorry. :(<!--content-->No problem and thanks sooooooooo much. You made me a great favor.<br />
<br />
Sam<!--content-->
 
Back
Top