Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6066109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:27:55+00:00 2026-05-23T09:27:55+00:00

Ive been working on my delete.php file to delete selected messages for literally hours

  • 0

Ive been working on my delete.php file to delete selected messages for literally hours on end without any headway. How would I delete messages with the codes I have set up?

Heres the code to how my delete.php is set up right now

<?php
    session_start();
    header("Location:inbox.php");

    $user = $_SESSION['username'];

    include 'connect.php';


   foreach($_POST['messages'] as $num => $messages_id)

        mysql_query("DELETE FROM messages WHERE messages_id='$messages_id' AND to_user='$user'");

    ?> 

Here’s the code to my entire inbox.php

<?php
require "connect.php";

echo "<hr><br><div id='mail'>";

// get the messages from the table.
$get_messages = mysql_query("SELECT messages_id FROM messages WHERE 

to_user='$userfinal' ORDER BY messages_id DESC") or die(mysql_error());
$get_messages2 = mysql_query("SELECT * FROM messages WHERE to_user='$userfinal' 

ORDER BY messages_id DESC") or die(mysql_error());
$num_messages = mysql_num_rows($get_messages);
// display each message title, with a link to their content
echo '<ul>';
for($count = 1; $count <= $num_messages; $count++)
{
    $row = mysql_fetch_array($get_messages2);
    $fromuser = $row['from_user'];
    $messageid = $row['messages_id'];
    $messagetitle = $row['message_title'];
    $messageread = $row['message_read'];
    $messagedate = $row['message_date'];



    echo " <form name='send' method='post' action='delete.php'><input type='checkbox' name='delete' value='$messageid'></td><font face='helvetica'><font size='3'>$fromuser</font></font> &nbsp; &bull; &nbsp;  <div align='right'><a href='read_message.php?messages_id=$messageid'>$messagetitle</a></div>
<center><hr></center>


";
}
?>
<input type="submit" name="Submit" value="Delete Selected">
</table>
</div>

Please help out before my head explodes

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:27:56+00:00Added an answer on May 23, 2026 at 9:27 am

    You are using header("Location:inbox.php"); in the second line of your code, so the rest of it never gets executed.

    Just move it to the end of the script, after you have deleted the messages you wanted to delete.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working with sessions, MVC design and object oriented PHP. Where should I
Hey guys, ive been working on this drop down for wayyy to long now.
Just a silly question that just cant figure out. Ive been working on iPad
I've been tracking down some memory leaks in a Javascript file I've been working
I've been working on a system where you can create-read-update-delete to/from a table in
i would think that a delete would be pretty simple, I haven't been able
I've been working on web apps for a while now, using php and then
I've been working with providers a fair bit lately, and I came across an
I've been working on a project that accesses the WMI to get information about
I've been working through Practical Common Lisp and as an exercise decided to write

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.