liamloveslearning Posted May 19, 2008 Share Posted May 19, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/ Share on other sites More sharing options...
AndyB Posted May 19, 2008 Share Posted May 19, 2008 There's no form opening/action/method or closing tag in that soup. Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545089 Share on other sites More sharing options...
947740 Posted May 19, 2008 Share Posted May 19, 2008 Do you have <form> tags? I do not see them in the script, but that does not mean you did not post them... Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545090 Share on other sites More sharing options...
sasa Posted May 19, 2008 Share Posted May 19, 2008 where you start and end form? (tags <form></form>) where you proces form Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545092 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2008 Author Share Posted May 19, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545094 Share on other sites More sharing options...
947740 Posted May 19, 2008 Share Posted May 19, 2008 What is the code for delete.php? Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545096 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2008 Author Share Posted May 19, 2008 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'"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545099 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2008 Author Share Posted May 19, 2008 also, this may seem really amateur and ridiculous, but my inbox check/delete works fine using this delete.php file, however my sentbox also relates to the same delete.php file, could this be the issue? as in i need a deletemail.php and deletesentmail.php? Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545103 Share on other sites More sharing options...
947740 Posted May 19, 2008 Share Posted May 19, 2008 I presume that the the session variable $_SESSION['kt_login_id'] is fine? Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545104 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2008 Author Share Posted May 19, 2008 yeah the session variable works fine Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545105 Share on other sites More sharing options...
sasa Posted May 19, 2008 Share Posted May 19, 2008 move this line to the end header("Location:member_inbox_2.php"); Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545109 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2008 Author Share Posted May 19, 2008 I've tried that only its not deleting, my data; theoretically with it being 2 different forms will I need 2 different delete.php files ? Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545116 Share on other sites More sharing options...
sasa Posted May 19, 2008 Share Posted May 19, 2008 if field id in your table messages_test is primary key you can remove < AND reciever='$user'> from sql and it works with both forms Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545131 Share on other sites More sharing options...
DarkWater Posted May 19, 2008 Share Posted May 19, 2008 You can usually handle forms and PHP logic in one file, actually. Why do you have a location header on like, the 4th line of your script? That's why they keep getting sent back. Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545146 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2008 Author Share Posted May 19, 2008 thanks sasa, that solved it 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? Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545195 Share on other sites More sharing options...
DarkWater Posted May 19, 2008 Share Posted May 19, 2008 What do you mean by a "URL message"? Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545204 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2008 Author Share Posted May 19, 2008 like a POST GET function passing the message string throught the url? ??? <?php echo KT_escapeAttribute(KT_getFullUri()); ?> <?php echo $_GET['message']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545214 Share on other sites More sharing options...
DarkWater Posted May 19, 2008 Share Posted May 19, 2008 I don't quite understand. o-O Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545227 Share on other sites More sharing options...
liamloveslearning Posted May 19, 2008 Author Share Posted May 19, 2008 ah nevermind, thanks for your help tho Quote Link to comment https://forums.phpfreaks.com/topic/106348-solved-quotdelete-selectedquot-not-submitting/#findComment-545229 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.