I'm trying to develop a customized user messaging system. Right now I have it pretty basic. It connects to a database, selects a row from a table according to the user name, then prints out the results.
Up to that point everything is ok.
The problem is when I try to delete the posts.
In the code I have the line that connects to the database as:
$result = mysql_query("SELECT id,sendto,sendfrom,msg,senddate FROM messages WHERE sendto='$user'");
while($data=mysql_fetch_row($result)){
The line that prints the deletion action is:
<a href="execute.php?id='.$data[0].'&user='.$user.'&action=Delete">Delete</a>
My execute.php script is:
if ( action == "Delete" ) {
$result = mysql_query("DELETE FROM messages WHERE id='.$id.'");
print 'Deleted ' .$what. ' from your message center.';
print '<a href="user.php?user='.$user.'">Return</a>';
} else {
print 'It didnt work out 🙁 Sorry.';
print '<a href="user.php?user='.$user.'">Return</a>';
}
Everytime I click on the 'Delete' link I get my Else statement, return, and the message is still there which means it didn't delete the row from the database.
I've looked in mysql.org under thier function list and I'm pretty sure i have the DELETE FROM line ok, it matches the examples and explanations they have on thier site.
Anyone have a clue what's going on here? Any help would be appreciated.