It cannot display the value of the checkbox,please tell me what wrong of it!
Thak you

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" c />
<title>Untitled Document</title>
</head>
<body>
<?php
if(isset($_POST["Sumbit"]))
{
$fruit=isset($_POST["apple"]) ? $_POST["apple"]:"";
if(isset($_POST["bananan"]))
{
if(!empty($fruit))
$fruit.=", ";
$fruit.=$_POST["bananan"];
}
if(isset($_POST["orange"]))
{
if(!empty($fruit))
$fruit.=", ";
$fruit.=$_POST["orange"]; 
} 
print"your faviours fruit is:".$fruit;
}
?>
<form id="form1" name="form1" method="post" action="fruit.php">
  <label>
  <input name="apple" type="checkbox" id="apple" value="apple" />
  </label> 
  apple
  <label>
  <input name="bananan" type="checkbox" id="bananan" value="bananan" />
  banana
  <input name="orange" type="checkbox" id="orange" value="orange" />
  </label>
orange         
<label>
<input type="submit" name="Submit" id="Submit" value="Submit" />
</label>
</form>
</body>
</html>

try following php code

<?php
if($_POST)
{
	$fruit=isset($_POST["apple"]) ? $_POST["apple"]:"";
	
	if(isset($_POST["bananan"]))
	{
		if(!empty($fruit))
		{
		$fruit.=", ";
		$fruit.=$_POST["bananan"];
		}
	}
	if(isset($_POST["orange"]))
	{
		if(!empty($fruit))
		{
		$fruit.=", ";
		$fruit.=$_POST["orange"]; 
		}
	} 
print"your faviours fruit is:".$fruit;
}
?>

It cannot display the value of the checkbox,please tell me what wrong of it!
Thak you

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" c />
<title>Untitled Document</title>
</head>
<body>
<?php
if(isset($_POST["Sumbit"]))
{
$fruit=isset($_POST["apple"]) ? $_POST["apple"]:"";
if(isset($_POST["bananan"]))
{
if(!empty($fruit))
$fruit.=", ";
$fruit.=$_POST["bananan"];
}
if(isset($_POST["orange"]))
{
if(!empty($fruit))
$fruit.=", ";
$fruit.=$_POST["orange"]; 
} 
print"your faviours fruit is:".$fruit;
}
?>
<form id="form1" name="form1" method="post" action="fruit.php">
  <label>
  <input name="apple" type="checkbox" id="apple" value="apple" />
  </label> 
  apple
  <label>
  <input name="bananan" type="checkbox" id="bananan" value="bananan" />
  banana
  <input name="orange" type="checkbox" id="orange" value="orange" />
  </label>
orange         
<label>
<input type="submit" name="Submit" id="Submit" value="Submit" />
</label>
</form>
</body>
</html>

Pl replace this line, Submit mis-spelled
if(isset($_POST["Submit"]))

Pl replace this line, Submit mis-spelled
if(isset($_POST["Submit"]))

Thank you very much!My problem had solved!

Thank you very much!My problem had solved!

Great!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.