Am still learning php. I really don't know what's wrong with this code, it keeps displaying errors when I try running it. I would really appreciate if it is checked out for me so I can know where the errors are. An alternate code would also be appreciated.
Code:
<html>
<head>
<?php
$ch1 = " unchecked";
$ch2 = "unchecked";
$ch3 = "unchecked";
$ch4 = "unchecked";
$ch5 = "unchecked";
if (isset($_POST["submit1"]))
{
if (isset($_POST["ch1"]))
{
$ch1 = $_POST["ch1"];
if ($ch1 == "word")
{$ch1 = "checked";}
}
if (isset($_POST["ch2"]))
{
$ch2 = $_POST["ch2"];
if ($ch2 == "key")
{$ch2 = "checked";}
}
if (isset($_POST["ch3"]))
{
$ch3 = $_POST["ch3"];
if ($ch3 == "excel")
{$ch3 = "checked;}
}
if (isset($_POST["ch4"]))
{
$ch4 = $_POST["ch4"];
if ($ch4 == "corel")
{$ch4 = "checked";}
}
if (isset($_POST["ch5"]))
{
$ch5 = $_POST['ch5'];
if ($ch5 == "power")
{$ch5 = "checked";}
}
}
?>
</head>
<body>
<form name = "form1" method = "post" action = "checkbox.php">
<input type = "Checkbox" name = "ch1" value = "word" <?php print $ch1; ?> >Msword
<P>
<input type = "Checkbox" name = "ch2" value = "key" <?php print $ch2; ?> >Passkey
<P>
<input type = "Checkbox" name = "ch3" value = "excel" <?php print $ch3; ?> >Excel
<P>
<input type = "Checkbox" name = "ch4" value = "corel" <?php print $ch4; ?> >Coreldraw
<P>
<input type = " Checkbox" name = "ch5" value = "power" <?php print $ch5; ?> >Powerpoint
<P>
<input type = "submit" name = "submit1" value = "Select your choices">
</form>
</body>
</html>
Comment