Jump to content


Photo

Checkbox Problem


  • Please log in to reply
1 reply to this topic

#1 wipeskim

wipeskim
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 July 2006 - 05:35 PM

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:


<?  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 ///////////////


?>

If someone can help me with this i appreciate,

Thanks to all

Mod edit : Please use code tags

#2 Drumminxx

Drumminxx
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts
  • LocationUSA

Posted 02 July 2006 - 06:51 PM

why not just use 1 form and then check which button was pressed

if (!empty($_POST['delete'])) {
   delete code here
}

if (!empty($_POST['edit'])) {
   edit code here
}


:: gucci.com ::
:: blockbuster.com ::

--------------------




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users