Jump to content

[SOLVED] "Delete Selected" not submitting


Recommended Posts

Hi guys,

Im having trouble with my delete button on my "sent messages" page; users have the option to radio check mail they want deleting then press delete, only once they press delete its not submitting there requests just re-directing them, heres my code if anybody could help out :) thanks

 

<table width="100%">
	<tr valign="middle">
	  <td width="4%" class="message_header">Check</td>
	  <td width="16%" class="message_header">Date</td>
	  <td width="145px" class="message_header">To</td>  
	  <td width="9%" class="message_header">Status</td>
	  <td width="145px" class="message_header">Subject</td>
	  		</tr>
	<?php
	//Ok cool, now we stick it all into an array and we will dispaly it now
	while($inbox = mysql_fetch_array($sqlinbox))
		{
		//These are the variables we have the id of the private message, we have the person who sent the message, we have the subject of the message, and yeah thats it
		$pm_id = $inbox['id'];
		$reciever = $inbox['reciever'];
		$subject = $inbox['subject'];
		$datetime = $inbox['datetime'];
		$replied = $inbox['replied'];

		//So lets show the subject and make that a link to the view message page, we will send the message id through the URL to that page so it can be displayed
		//And also let the person wee who sent it to them, if you want you can make that some sort of a link to view more stuff about the user, but Im not doing that here, I did it for my game though, pretty much same as the viewmsg.php page but a different page, and with the senders id
		//And finally the checkboxes that are all stuck into an array and if they are selected we stick the private message id into the array
		//I will only let my users have a maximum of 50 messages, remeber that ok? Because that's the value I will use later for things
		?>
		<tr valign="middle">
		  <td width="4%" align="center" class="message_rows"><input name="pms[]" type="checkbox" value="<?php echo $pm_id; ?>" /></td>
		  <td width="16%" align="left" class="message_rows"><?php echo $datetime; ?></td>
		  <td class="message_rows"><?php echo $reciever; ?></td>
		  <td width="9%" class="message_rows"><?php echo $replied; ?></td>
		  <td class="message_rows"><a href="mail_viewmsg.php?msg_id=<?php echo $pm_id; ?>" class="message_rows_subject"><?php echo $subject; ?></a></td>
      </tr>
		<?php
		//This ends the while loop
		}
	?>
	<tr>  
	<td height="10" colspan="7"></td>
	</tr>
	<tr valign="middle">
	  <td colspan="7"><table class="footerCell" width="100%" cellpadding="0" cellspacing="0">
              <tr>
                <th align="left" valign="middle" bgcolor="#6698CB" style="padding-left:8px"></th>
                <th colspan="3" align="right" bgcolor="#6698CB"> <input name="Submit" type="submit" value="Delete Selected" />                </th>
            </tr>
            </table></td>
	  </tr>
	</table>

Link to comment
Share on other sites

sorry, thought id copied it  :-[

 

  <form name="send" method="post" action="delete.php">
	</p>
	<table width="100%">
	<tr valign="middle">
	  <td width="4%" class="message_header">Check</td>
	  <td width="16%" class="message_header">Date</td>
	  <td width="145px" class="message_header">To</td>  
	  <td width="9%" class="message_header">Status</td>
	  <td width="145px" class="message_header">Subject</td>
	  		</tr>
	<?php
	//Ok cool, now we stick it all into an array and we will dispaly it now
	while($inbox = mysql_fetch_array($sqlinbox))
		{
		//These are the variables we have the id of the private message, we have the person who sent the message, we have the subject of the message, and yeah thats it
		$pm_id = $inbox['id'];
		$reciever = $inbox['reciever'];
		$subject = $inbox['subject'];
		$datetime = $inbox['datetime'];
		$replied = $inbox['replied'];

		//So lets show the subject and make that a link to the view message page, we will send the message id through the URL to that page so it can be displayed
		//And also let the person wee who sent it to them, if you want you can make that some sort of a link to view more stuff about the user, but Im not doing that here, I did it for my game though, pretty much same as the viewmsg.php page but a different page, and with the senders id
		//And finally the checkboxes that are all stuck into an array and if they are selected we stick the private message id into the array
		//I will only let my users have a maximum of 50 messages, remeber that ok? Because that's the value I will use later for things
		?>
		<tr valign="middle">
		  <td width="4%" align="center" class="message_rows"><input name="pms[]" type="checkbox" value="<?php echo $pm_id; ?>" /></td>
		  <td width="16%" align="left" class="message_rows"><?php echo $datetime; ?></td>
		  <td class="message_rows"><?php echo $reciever; ?></td>
		  <td width="9%" class="message_rows"><?php echo $replied; ?></td>
		  <td class="message_rows"><a href="mail_viewmsg.php?msg_id=<?php echo $pm_id; ?>" class="message_rows_subject"><?php echo $subject; ?></a></td>
      </tr>
		<?php
		//This ends the while loop
		}
	?>
	<tr>  
	<td height="10" colspan="7"></td>
	</tr>
	<tr valign="middle">
	  <td colspan="7"><table class="footerCell" width="100%" cellpadding="0" cellspacing="0">
              <tr>
                <th align="left" valign="middle" bgcolor="#6698CB" style="padding-left:8px"></th>
                <th colspan="3" align="right" bgcolor="#6698CB"> <input name="Submit" type="submit" value="Delete Selected" />                </th>
            </tr>
            </table></td>
	  </tr>
	</table>

Link to comment
Share on other sites

delete.php

 

<?php require_once('Connections/db99.php'); ?>
<?php
session_start();
header("Location:member_inbox_2.php");

$user = $_SESSION['kt_login_id'];

//We need to get the total number of private messages the user has
$sql = mysql_query ("SELECT pm_count FROM members WHERE member_id='$user'");
$row = mysql_fetch_array ($sql);
$pm_count = $row['pm_count'];
            
//A foreach loop for each pm in the array, get the values and set it as $pm_id because they were the ones selected for deletion
foreach($_POST['pms'] as $num => $pm_id)
{
//Delete the PM
mysql_query("DELETE FROM messages_test WHERE id='$pm_id' AND reciever='$user'");

//Subtract a private message from the counter! YAY!
$pm_count = $pm_count - '1';

//Update that users pm count. . .
mysql_query("UPDATE members SET pm_count='$pm_count' WHERE member_id='$user'");
}
?> 

Link to comment
Share on other sites

thanks sasa, that solved it  ;D

 

and thanks for the input everyone, in regards to your post darkwater, im not entirely sure what<header("Location:mail_inbox.php");> primarily does, ive used a tutorial to go about producing this messaging system, is there a way I can echo a url message on the page using the delete.php file?

 

Link to comment
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.