Click to See Complete Forum and Search --> : PHP/HTML scope issue


nanode
03-01-2001, 12:42 PM
On my site I include a common file that supplies an HTML header and a handful of PHP variables. The variables are simply color values, that get used in each page that includes the header file.

This makes it really easy to change the font or background color of my entire site - just change 1 file.

Anyhow, I was wondering how I could implement dynamic changes to those color variables. I considered making a small form in HTML, but I'm not sure how I could POST to it since it's an included file and not actually a true webpage.

Here's the included file in question:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<title>yunt.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body
bgcolor="000000"
text="000000"
LINK="000000"
ALINK="000000"
VLINK="000000"
<?php
$bgimg = "/images/backgrounds/wind_paper.gif";
echo "background=$bgimg";
echo ">";
?>


<style>A:hover {color:black}</style>
<CENTER>

<?php
$bg = "#CCCCCC";
$altbg = "#FFFFFF";

$font = "#000000";
$altfont = "#FFFFFF";
?>


<?php

echo "\n<table border=0 cellspacing=0 cellpadding=0 width=100% bgcolor=#000000><tr><td>";
echo "\n<table cellpadding=0 cellspacing=1 width=100% border=0><TR><TD>";
echo "\n<table cellpadding=3 cellspacing=0 width=100% border=0>";
echo "\n<TR><TD colspan=4 align=center bgcolor=$bg>";
echo "\n<FONT face=arial color=$font size=6>yunt.net</FONT></TD></TR>";

echo "\n<TR align=center bgcolor=$bg><TD><A HREF=\"/\" style=\"text-decoration: none\">";
echo "\n<FONT face=arial color=$font size=2>home</FONT></A></TD>";

echo "\n<TD><A HREF=\"/network\" style=\"text-decoration: none\">";
echo "\n<FONT face=arial color=$font size=2>network</FONT></A></TD>";

echo "\n<TD><A HREF=\"mailto:seanyunt@hotmail.com\" style=\"text-decoration: none\">";
echo "\n<FONT face=arial color=$font size=2>email me</FONT></A></TD>";

echo "\n<TD><A HREF=\"/photo_gallery\" style=\"text-decoration: none\">";
echo "\n<FONT face=arial color=$font size=2>images</FONT></A></TD></TR>";

?>

</table>
</TD></TR></TABLE>
</TD></TR></TABLE>
<HR>
<font size="2" face="Helvetica, Arial, San Serif">

The page that includes it supplies all the closing tags.

I don't need to do this, so I won't bust my *** working on it, but I think it'd be cool.

jcrowe
03-01-2001, 02:58 PM
how bout this.

set a default color value.
form that allows picking a color.
That form sets a cookie.
check for cookie in comman include after you set defaults.
if (cookie)
change value of color

I did this once with ASP, and it worked like a charm.

Stuka
03-01-2001, 04:18 PM
I think the cookie thing would be necessary for 'user preferences', but if you just want it as an admin type thing, couldn't you write a script that wrote the appropriate info into the header file?

nanode
03-01-2001, 06:27 PM
I solved my problem.

I'm not using cookies - the user must select a theme each time they visit, but that theme stays the same throughout site navigation.

http://yunt.net

It's just for fun - but I'm glad I know how to do this now.

Thanks for the replies.

nanode
03-01-2001, 06:32 PM
BTW: just ask and I'll paste code if anyone is curious. All I did was POST to $URL, which is a PHP variable for the current url. That's how it can POST to any page that includes it, and variable scope too.

kmj
03-01-2001, 06:36 PM
That's a damned sleek site, nanode. Too bad I'm too lazy to bother learning PHP, or I'd take you up on the offer.

nanode
03-01-2001, 08:07 PM
kmj:

thanks - but it's really kludgey under the skin. I've posted some of the code before and been scolded by sweede :)

kmj
03-01-2001, 09:43 PM
That's how ya' learn, right? :)

Sweede
03-02-2001, 04:23 AM
Originally posted by nanode:
kmj:

thanks - but it's really kludgey under the skin. I've posted some of the code before and been scolded by sweede :)

hahaha, non-sense :)

got any code that needs a review, just lemme know :)

you can almost always find me on irc.openprojects.net, handle sweede (go figure), or sweede@gallatinriver.net