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
https://forums.phpfreaks.com/topic/24491-deleting-entry-from-table/
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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.