Lottery Game play

Hello Folks;

On the picture is my front-end then this is my loop code, and the action code but each time i thick on the respective box am expected to get the value number of the boxes i checked but i keep getting this error Warning: Undefined array key "thick" in C:\Users\pc\Backend_class01\play_game.php on line 12
please i need to know where am not doing it right being that the variable is actually declared on the action page


    <div id = "wrapper" >
<?php
$play = $_POST["thick"];
for ($i=1; $i <= 30; $i++) {
    echo $play.'<br>';

}
   
?>

    </div>

<form action="play_game.php" method="post">
<div id = "wrapper">
<?php
for ($i = 1; $i<= 30; $i++) {
    echo '<div>';
    echo $i ;
    echo' <input type="checkbox" name="thick '.$i.'" value = "'.$i.'"> ';
     echo '</div>'.PHP_EOL;
     
}
?>
<input type="submit" value="play">

</div>
</form>  

  • 2 Comments
  • 111 Views
  • Share:

2 Comment

image
5 months ago

I modified my action page to this by passing $i through and using if statement to condition when value is greater than zero and am getting all the all the number in the loop instead of the values i thick

image
5 months ago

Number one, you are looping through an array and displaying a checkbox based on its elements. I noticed that the array is named 'thick' and you are concatenating the index to form names like 'thick0', 'thick1', and so on. However, on the receiving end, you are only receiving 'thick'. This discrepancy is likely the reason it is not working.