我想知道如何检测和取消选中复选框并使其执行和操作。基本上,如果未选中该复选框,则应加载另一页。这似乎没有用,有什么帮助吗?
<?php
if(!isset($_POST['checkbox1']))
{
$swag=fopen("empty.php","r");
}
?>
HTML位:
<html>
<title>Zeromilez | Shop</title>
<!--The following script tag downloads a font from the Adobe Edge Web Fonts server for use within the web page. We recommend that you do not modify it.--><script>var __adobewebfontsappname__="dreamweaver"</script><script src="http://use.edgefonts.net/source-sans-pro:n2,n4:default;atomic-age:n4:default.js" type="text/javascript"></script>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<div id="header-wrapper">
<div id="header" class="container">
<div id="logo">
<h1><a href='#'>Zeromilez.com</a></h1>
</div>
<div id="menu">
<ul>
<li ><a href="index.php" accesskey="1" title=""><i class="fa fa-home fa-fw fa-2x"></i> Home</a></li>
<li class="current_page_item"><a href="#" title="" class="active" accesskey="4"><i class="fa fa-shopping-cart fa-2x"></i> shop</a></li>
<li><a href="feedback.php" accesskey="5" title=""><i class="fa fa-envelope fa-2x"></i> Feedback</a></li>
</ul>
</div>
</div>
<div id="banner" class="container"></div>
</div>
<div class="wrapper">
<form id="form1" name="form1" method="POST">
<div id="three-column" class="container">
<div id="tbox1">
<div class="title">
<p>
<input name="name" type="text" id="textfield" style="background-color:#4D4D4D;margin:0;color:#FFF; text-align:center;" value="Fox's berries-500gms" disabled>
</p>
<h2><img src="fox.jpg" height="90" width="100"></h2>
</div>
<p>
<input name="cost" type="text" id="textfield2" value="Rs 100" style="background-color:#4D4D4D;color:#fff; text-align:center; padding:0; margin:0;" disabled>
</p>
<p>
<input type="checkbox" name="checkbox1" id="checkbox1">
Add to cart
<label for="checkbox1"></label>
</p>
</div>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>
<input type="submit" name="submit" id="submit" value="Submit">
</p>
<p> </p>
</div>
<input type="hidden" name="MM_insert" value="form1">
</form>
</div>
<div id="copyright" class="container">
<p>© Zeromilez.com 2014 | All rights reserved | Made with ❤ in Bangalore, India
</p><p>Follow us:<br/><img src="facebook.png" width="30" height="30" alt=""/><img src="twitter.png" width="30" height="30" alt=""/><img src="google.png" width="30" height="30" alt=""/><img src="yahoo.png" width="30" height="30" alt=""/><img src="pinterest.png" width="30" height="30" alt=""/></p><div id ="about_me" >
<p>About Me:<br/><img src="about_me.png" width="100" height="100" alt=""><br/>Hi, I am Mohit Bhasi, a 16 year old aspiring web developer. Hope you all enjoy my first website :)</p></div>
</h4></div>
</body>
</html>
答案 0 :(得分:0)
当在php端接收POST参数时,如果相对于复选框的参数进来,那是因为选中了复选框。如果参数没有进入POST参数,则取消选中。
您可以这样做:
if(isset($_POST['checkbox_parameter']){
echo "Checkbox is selected!";
}
else {
echo "Checkbox not selected.";
}