HTML FILE IS:
<html>
<body bgcolor="yellow" text="red" >
<form method="get" action="cookie6.php">
<p>Which car you want to buy?<P>
<TABLE border=2>
<TR><TD><input type="checkbox" value ="15" name="text[]"><TD>Ferrari<TD bgcolor="blue" width="15px"> 15million</td></TR>
<TR><TD><input type="checkbox" value ="35" name="text[]"><TD>Mercedes<TD bgcolor="red"width="15px"> 35million</td></TR>
<TR><TD><input type="checkbox" value ="50" name="text[]"><TD>Bugatti<TD bgcolor="yellow"width="15px">50million</td></TR>
</TABLE>
<input type="hidden" value="1" name="check" >
<p>
<input type="submit" value="refresh" >
</form>
</body>
</html>
PHP FILE IS :
<?php
// echo "you want to buy<P>";
// if(isset($_GET['check']))
// {$car=array();
// if(isset($_GET['text1']))
// {echo $_GET['text1']." ferrari<br>";}
// else {}
// if(isset($_GET['text2']))
// {echo $_GET['text2']." merc<br>";}
// else {}
// if(isset ($_GET['text3']))
// {echo $_GET['text3']." bugatti<br>";}
// else {}
// }
if(isset($_GET['check']))
{
$sel_cars="";
$count=count($_GET['text']);
for($i=0;$i<$count;$i++)
{
$sel_cars=$sel_cars.$text[$i]." ";
}
}
?>
This is a basic code for finding which cars user selected.My program works if the checkboxes in the HTML file have different names but not if they have the same name.
Please I have tried it for more than 2 hours .....
What is the solution if checkboxes have the same name?