Jump to content

deleting entry from table


hustler

Recommended Posts

Hi i have system where registered users and admin can send messages to each other.

messages is sent thru sendpm.php

and read thru readpm.php

everything works fine but i need to make an option to delete the message.

How can i create a "delete" link in front of each message so that when it is pressed the message gets deleted.??

This are the fields in "messages" table:-
message_id
message_to
message_from
message_subject
message
senton

Link to comment
Share on other sites

have a link to something like "[code=php:0]delete_pm.php?id=<?=$message_id?>[/code]"

on the delete_pm page use $_GET to get the message id eg:

[code=php:0]$message_id = $_GET['id'][/code]

Then you need to have some kind of security to ensure that the person deleting the message is authorised to do so.  Perhaps compare the users id to the message_to? (Im assuming certain things about your database structure here, if you dont get what I mean then just ask me to elaborate)

Then use

[code=php:0]mysql_query("DELETE FROM messages WHERE message_id = '$message_id'")or die(mysql_error());[/code]

Is that what you were after?
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.