Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php - css switcher 1

Status
Not open for further replies.

DimisD

Technical User
Feb 7, 2007
15
GR
Hi there,

I have a problem running a php css switcher script. Although i followed the instructions exactly as they are written in " it doesn't work.


Details - [My test site is www.goalit.gr]

1. I have put in the index.html file the codes:
a) HEAD:
<link rel="stylesheet" type="text/css" media="screen" title="User Defined Style" href="<?php echo (!$sitestyle)?'first':$sitestyle ?>.css" />

b) BODY:
<a href=" FIRST style!</a>
<a href=" SECOND style!</a>



2. The switcher.php file is:
<?php
setcookie ('sitestyle', $set, time()+31536000,'/', 'goalit.gr', '0');
header("Location: $HTTP_REFERER");
?>

3. The css files are named first.css and second.css

Does anybody has an idea.
Thank you
 
Hi

An acronym comes in my mind... UTSL - Use The Source Luke. :)

Ask your browser to show you the page source. You will see that your PHP code was not evaluated because... that is a pure HTML file.
Code:
<link rel="stylesheet" type="text/css" media="screen" title="User Defined Style" href="<?php echo (!$sitestyle)?'first':$sitestyle ?>.css" />

Feherke.
 
Well, thank you feherke for your reply, but i don't really understand your point. You see, my knowledge on php is zero. Can you propose a solution? Can i do something to fix the problem?

thank you
 
Hi

That style switching is based on PHP scripting. PHP scripts are executed by the PHP interpreter on the web server's request. The web servers usually invoke the PHP interpreter only for files with .php extension. Your file has .html extension. So PHP code inserted in you .html file is not executed because it is not parsed by the PHP interpreter.

Rename your from index.html to index.php .

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top