//11-7.php
<html>
<head>
<title>用cookie实现改变网站风格</title>
<?php
echo"<LINK href='style".$_COOKIE["style"].".css'rel=stylesheet>";
?>
</head>
<body>
<table>
<p>用Cookie实现改变网站风格</p>
<tr>
<td><a href=11-8.php?style=1>风格1</a></td>
<td><a href=11-8.php?style=2>风格2</a></td>
<td><a href=11-8.php?style=3>风格3</a></td>
<td><a href=11-8.php?>无样式</a></td>
</tr>
<tr>
<td colspan=4><h1>慧能</h1></td>
</tr>
<tr>
<td colspan=4><h1>菩提本无树</h1></td>
</tr>
<tr>
<td colspan=4><h1>明镜亦非台</h1></td>
</tr>
<tr>
<td colspan=4><h2>本来无一物</h2></td>
</tr>
<tr>
<td colspan=4><h2>何处惹尘埃</h2></td>
</tr>
<tr>
<td colspan=4><h2>慧能</h2></td>
</tr>
<tr>
<td colspan=4><h1>慧能</h1></td>
</tr>
//11-8.php
<?php
$style=$_GET["style"];
setcookie("style","$style",time()+60*60*24);
?>
<html>
<head>
<title>正在处理</title>
</head>
<meta http-equiv="refresh"content="0;url=11-7.php">
<body>正在处理
</body>
</html>
//style1.css
BODY,TD{
font:400 normal 100% Arial,Helvetica,sans-serif;
}
A{
color:#FFD700;
text-decoration:none;
background:Black;
width:80px;
padding:3px;
}
A:hover
{
background:Maroon;
}
H1{
background:#228B22 none;
color:#FF6347;
font-size:150%;
text-align:right;
}
H2{
background:#FFDEAD none;
color:#000000;
font-size:110%;
}
P{
background:#A9A9A9 none;
color:#2F4F4F;
font:400 normal 120% Arial,Helvetica,sans-serif;
text-decoration:none;
padding:2% 2% 2% 2%;
border:1px solid Black;
}
//style2.css
body{
background-color:#FFFFF0;
}
a{
background:#FFFFAA;
text-decoration:none;
}
a:hover{
background:#FFFFF0;
border:thin solid Black;
}
h1{
text-align:center;
}
h2{
text-align:center;
}
p{
text-align:center;
font-size:20px;
}
//style3.css
body{
background-color:#FFFFF0;
background-image:uri(image001.jpg);
}
a{
text-decoration:none;
background-color:#0000CD;
color:White;
font-size:15px;
}
a:hover{
background-color:Maroon;
}
h1{
text-align:center;
background-color:#FAFAD2;
color:Blue;
}
h1{
text-align:center;
background-color:#F5F5DC;
color:Green;
border:1px solid Black;
}
p{
text-align:center;
border:5px ridge;
font-size:40px;
}
//style1
//style2
//style3