Jump to content

Recommended Posts

I'm having trouble trying to create a delete function to delete inbox messages.

 

This is my delete form

 

<?php
include 'gradnetconn.php';
require_once ('webpage.class.php');
include 'functions.php';
session_start();
$messageTo = $_SESSION['userID'];

  if (!(isset($_SESSION['userID']) && $_SESSION['userID'] != '')) {
   echo "Log in to send a message" ;
   header ("Location: login.php");
   exit();
  } else {
  echo "You aree logged in, please feel free to delete a message ";
 }
  $sql="SELECT * FROM gn_messages WHERE messageTo = $messageTo AND messageDeleted = '0'
   ORDER BY messageDate DESC";


$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="deletemessagesprocess.php">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete A Message</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Message ID</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>From</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Subject</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Messge Contents</strong></td>
</tr>
 <?php
  while($rows=mysql_fetch_array($result)){


 ?>
<tr>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['messageID']; ?>"></td>
<td bgcolor="#FFFFFF"><? echo $rows['messageID']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['messageFrom']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['messageSubject']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['messageBody']; ?></td>
</tr>
 <?php
 }
 ?>

<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>

 

This is my delete form process file:

 

<?php
include 'gradnetconn.php';
include 'functions.php';
session_start();
{
for($i=0;$i<$count;$i++){
 $del_id = $chk[$i];
 $sql = "DELETE FROM gn_messages WHERE messageID='$del_id'";
 $result = mysql_query($sql);
}
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">";
}
}
mysql_close();
?>

 

 

I know this is completetly wrong, I need help on it, how to get the processing right in the second file so it actually deletes the messages that are checked.

Any soolutions/ advice and talking my through code solutions would be so great!

Link to comment
https://forums.phpfreaks.com/topic/274223-php-mysql-checkbox-delete-messages/
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.