mardi 17 février 2015

How can I keep the checkbox checked after I submit a form using PHP?

I'm trying to get a value from post array then store it in a variable then use the value to keep the checkbox selected. Here's what I'm trying:


I have this line above the foreach:



<input type='checkbox' name='$plyrMtchResult 'value=''>$plyrMtchResult</input> //This line works fine

//then when I submit the form the foreach loop runs here.

foreach($_POST as $value => $key)
{

$post_Value= str_replace("_", " ", $value);

"<input type='checkbox' name='$post_Value' value='post_valuebValue' checked='checked'>$post_valuebValue</input>";

}


My issue seems similar to what I found here but mine is not working.


How can I keep the checkbox checked after I submit the form.





Aucun commentaire:

Enregistrer un commentaire