Jump to content

Recommended Posts

Hi

I am having trouble using multiple forms with the checkbox,

i am listing results from the database such as the name of the person and the reference number and on the listings i have the checkbox to select the User using the 2 forms to perform the actions one for delete the selected users and other to multiple edit the Users information.

The problem is that is only running the Delete User when i press the Edit User button it doesn't show any values from the checkbox i think the form buttons are entering
in  conflict. I tryed to close the Edit user Form </form> before the While loop but that doesn't run the checkbox values also.

Is there any other way to perform this?

This is the code that i am using , on the second file that is actions.php i just put to print the checkbox values:


[code]
<?  echo "<form id='form1' action='actions.php?action=delete_user' method='post' enctype='multipart/form-data' name='form1'>";    ?>
 
<input type="submit" name="delete" value="Delete User" />
 

<?  echo "<form id='form2' action='actions.php?action=edit_user  ' method='post' enctype='multipart/form-data' name='form2'>";  ?>
   
<input type="submit" name="edit" value="Edit user" />



<? while($result = mysql_fetch_array($sql))    {  ?>


<?

$ref=$result["reference"];
          echo "<INPUT TYPE='checkbox' NAME='checkbox[]' VALUE='$ref'>";

?>

<? 

printf("<font color='#000000'>%s</font>",$result["reference"]); 
printf("<font color='#000000'>%s</font>",$result["user_name"]); 


?>

<?  }  ?>
 
 
</form>
</form>





  -> File actions.php


<?


require ("setup.php");

$link=mysql_connect("$host","$dbuser","$dbpass");
mysql_select_db("$bdname");



switch ($action) {


  case "delete_user":
 

  $checkbox_cnt  = count($checkbox);

  for ($i = 0; $i < $checkbox_cnt; $i++)
  {
    echo $checkbox[$i];


}
 
break;


case "edit_user":
 

  $checkbox_cnt  = count($checkbox);

  for ($i = 0; $i < $checkbox_cnt; $i++)
 
{    echo $checkbox[$i];  }
 
break;




} // End of Switch Case ///////////////


?>[/code]

If someone can help me with this i appreciate,

Thanks to all

Mod edit : Please use code tags
Link to comment
https://forums.phpfreaks.com/topic/13474-checkbox-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.