wipeskim Posted July 2, 2006 Share Posted July 2, 2006 HiI 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 allMod edit : Please use code tags Link to comment https://forums.phpfreaks.com/topic/13474-checkbox-problem/ Share on other sites More sharing options...
Drumminxx Posted July 2, 2006 Share Posted July 2, 2006 why not just use 1 form and then check which button was pressed[code]if (!empty($_POST['delete'])) { delete code here}if (!empty($_POST['edit'])) { edit code here}[/code] Link to comment https://forums.phpfreaks.com/topic/13474-checkbox-problem/#findComment-52138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.