我在提交li
代码时遇到问题,只是提交我的数据没有改变。这是代码:
<?php
$theme1 = business;
$theme2 = modern;
$theme3 = web2;
if(isset($_POST['style']))
{setcookie('style', $_POST['style'], time()+(60*60*24*1000));
$style=$_POST['style'];}
elseif(isset($_COOKIE['style']))
{$style=$_COOKIE['style'];}
else
{$style=$theme1;}
echo "
<link href='"; $style; echo".css' rel='stylesheet' type='text/css' />
<form action='".$_SERVER['PHP_SELF']."' method='post' id='myForm'>
<li onclick='myForm.submit();' value='$theme1'> business</li>
</form>
";
?>
该代码确实在网站上提交,但不会更改数据。该表单是使用选择选项样式制作的。这是代码:
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<select name="style">
<option type="submit" <?php echo "value='$theme1'";if($style == $theme1){echo "selected='selected'";}?>><?php echo $theme1; ?></option>
<option type="submit" <?php echo "value='$theme2'";if($style == $theme2){echo "selected='selected'";}?>><?php echo $theme2; ?></option>
<option type="submit" <?php echo "value='$theme3'";if($style == $theme3){echo "selected='selected'";}?>><?php echo $theme3; ?></option>
</select>
<input type="submit">
</form>
li
我认为缺少一些信息是有问题的。我的代码有什么问题?