Jump to content

[SOLVED] get POST fileds


jkkenzie

Recommended Posts

I have this code that generates fields:

$order=0;
$count2=1;
while($order < $count)
{
echo "<input type='checkbox' name='".$country[$order]."' value = ' ".$count2."'>".$country[$order]. "<br />";
$order++;
$count2++;
}

 

I would like to get checked checkboxes values to variables into code below:

<?php
if (isset($_POST['continue']))
{
   //I need to have the checked values to variables here
}
?>

 

any help?

Link to comment
https://forums.phpfreaks.com/topic/130414-solved-get-post-fileds/
Share on other sites

okay.. first change

echo "<input type='checkbox' name='".$country[$order]."' value = ' ".$count2."'>".$country[$order]. "<br />";

to

echo "<input type='checkbox' name='myorders[]' value = ' ".$count2."'>".$country[$order]. "<br />";

myorders can be anything just make sure you have the brackets []

 

now to display

<?php
if (isset($_POST['continue']))
{
   //I need to have the checked values to variables here
   foreach($_POST['myorders'] as $mo)
   {
      //only the check boxes appear
      echo "$mo<br>";
   }
}
?>

 

*untested but should be fine

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.