Raga ho fatto uno script che mi mette a secondo della scelta dell'utente un foglio di style differente , ma mi da due errore
1) non carica nella form i file css
2) mi da un notice
Notice: Undefined index: style in C:\xampp\htdocs\trucchiphp\index.php on line 13
Questo è lo script molto semplice
codice:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<?php
$style = "default";
if($_GET['style'])
$style =$_GET['style'];
$files= array();
$dh = opendir("styles");
while($file = @readdir($dh)){
if(preg_match("/[.]css$/", "", $file))
{
$file = preg_replace("/[.]css$/", "", $file);
$files []= $file;
}
}
?>
<style type="text/css" media="all">@import url(styles/<?php echo ($style);?>.css);</style>
</head>
<body>
<table width="800px">
<tr>
<td width='200px' class="menu" valign='top'>
<div class="menu-active"><a href="home.php">Home</a></div>
<div class="menu-inactive"><a href="faq.php">faq</a></div>
<div class="menu-inactive"><a href="contact.php">contatti</a></div>
</td>
<td width='600px' valign='top'>
<table class="box">
<tr>
<td class="box-title">
Importanti informazioni
</td>
</tr>
<tr>
<td class="box-content">
lots of information about important events and stuff
</td>
</tr>
</table>
</td>
</tr>
</table>
<form>
Style:<select name="style">
<?php
foreach ($files as $file){?>
<option value="<?=($file);?>"
<?=($file==$style ? "selected":"");?>>
<?=($file);?>
</option>
<?php } ?>
</select>
<input type="submit" value="Select">
</form>
</body>
</html>