Jump to content

Recommended Posts

hey i have a user log in system with mail. now, it all works, however, the thing that doesn't seem to work is the actually DELETING the messages into the trash can. but sending works fine. here is the code for delpm.php. please tell me if im doing something wrong!!! THANKS IN ADVANCE
[code]
<?
session_start();
?>
<? error_reporting(E_ERROR);?>
<?php
include 'dbconnect.php';
include 'styleb.css';
if (isset($_SESSION['user']))
  {
    $user=$_SESSION['user'];
    $getuser="SELECT * from register where userid='$user'";
    $getuser2=mysql_query($getuser) or die("Could not get user info");
    $getuser3=mysql_fetch_array($getuser2);
    print "<center>";
    print "<table class='maintable'>";
    print "<tr class='linktable'><td><center>Delete PM</td></tr>";
    print "<tr class='posttable'><td>";
   $user2=$_SESSION['user'];
$ID = $_POST['id'];
    $getyourpms="SELECT * from pm as a,register as b where a.reciever='$user' and b.userid=a.sender and subject='$ID'";
    $getyourpms2=mysql_query($getyourpms) or die(mysql_error());
    while($getyourpms3=mysql_fetch_array($getyourpms2))
     $trash="INSERT into trash(sender,reciever,date,subject,message,status,time)
value('$getyourpms3[sender]','$getyourpms3[reciever]','$getyourpms3[date]','$getyourpms3[subject]','$getyourpms3[message]','$getyourpms3[status]','$getyourpms3[time]')";
       mysql_query($trash) or die("Could not put in trash can");
  
       $delpm="DELETE FROM pm where reciever='$user' and subject='$ID'";
       mysql_query($delpm) or die("Could not delete message");
       print "PM deleted, back to <A href='pmbox.php'>PM Main</a>";

}
    else
    {
       print "Are you sure you want to delete this PM?<br>";
       print "<form action='delpm.php' method='post'>";
       print "<input type='submit' name='submit' value='delete'></form>";
    
}

  
  

print "</td></tr></table>";      
    
  
?>

[/code]
Link to comment
https://forums.phpfreaks.com/topic/6515-please-help/
Share on other sites

All the cases where you use $var, $var2 $var3 etc etc. just use $var each time - help teh server out a little bit.

Why not leave all the mesages where they are - add one filed to you database 'trash' and have it set no 'n' or 'y'. Just show the ones marked 'y' in teh trash can and the rest in inbox; would probably help u in the ong run. You can then just update that field whne the user has checked against any messages.
Link to comment
https://forums.phpfreaks.com/topic/6515-please-help/#findComment-23645
Share on other sites

[!--quoteo(post=361387:date=Apr 3 2006, 06:05 PM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Apr 3 2006, 06:05 PM) [snapback]361387[/snapback][/div][div class=\'quotemain\'][!--quotec--]
All the cases where you use $var, $var2 $var3 etc etc. just use $var each time - help teh server out a little bit.


[/quote]
Well, that is becuase it will NOT work that way. they way that it was designed with not allow that to work. trust me.

And i have NO idea how to do the 2nd part you said.
Link to comment
https://forums.phpfreaks.com/topic/6515-please-help/#findComment-23670
Share on other sites

Of course using $var every time will work. Not the best practice though. I would give your variables meaning names such as $select_query $select_result etc.

The rest is simple:
Add a new column to your `pm` table which is called `trash`.
Set the default value of `trash` to false - or no - or 0
When someone deletes their message, dont ACTUALLY delete it, just change the value of the `trash` field to true - or yes - or 1.
Link to comment
https://forums.phpfreaks.com/topic/6515-please-help/#findComment-23674
Share on other sites

[!--quoteo(post=361416:date=Apr 3 2006, 07:40 PM:name=khendar)--][div class=\'quotetop\']QUOTE(khendar @ Apr 3 2006, 07:40 PM) [snapback]361416[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The rest is simple:
Add a new column to your `pm` table which is called `trash`.
Set the default value of `trash` to false - or no - or 0
When someone deletes their message, dont ACTUALLY delete it, just change the value of the `trash` field to true - or yes - or 1.
[/quote]
I really don't know how to do that. PLEASE WALK me through that. Here is DELPM.php
[code]
<body bgcolor="green">
<? error_reporting(E_ERROR);?>
<?php

include 'dbconnect.php';
include 'styleb.css';
session_start();




if (isset($_SESSION['user']))
  {
    $user=$_SESSION['user'];
    $getuser="SELECT * from register where userid='$user'";
    $getuser2=mysql_query($getuser) or die("Could not get user info");
    $getuser3=mysql_fetch_array($getuser2);
    print "<center>";
    print "<table class='maintable'>";
    print "<tr class='linktable'><td><center>Delete PM</td></tr>";
    print "<tr class='posttable'><td>";
   $user2=$_SESSION['user'];
$ID = $_POST['id'];
    $getyourpms="SELECT * from pm as a,register as b where a.reciever='$user' and b.userid=a.sender and subject='$ID'";
    $getyourpms2=mysql_query($getyourpms) or die(mysql_error());
    while($getyourpms3=mysql_fetch_array($getyourpms2))
     $trash="INSERT into trash(sender,reciever,date,subject,message,status,time)
value('$getyourpms3[sender]','$getyourpms3[reciever]','$getyourpms3[date]','$getyourpms3[subject]','$getyourpms3[message]','$getyourpms3[status]','$getyourpms3[time]')";
       mysql_query($trash) or die("Could not put in trash can");
  
       $delpm="DELETE FROM pm where reciever='$user' and subject='$ID'";
       mysql_query($delpm) or die("Could not delete message");
       print "PM deleted, back to <A href='pmbox.php'>PM Main</a>";

}
    else
    {
       print "Are you sure you want to delete this PM?<br>";
       print "<form action='delpm.php' method='post'>";
       print "<input type='submit' name='submit' value='delete'></form>";
    
}

  
  

print "</td></tr></table>";      
    print "<font size='1'>Script Produced by <A href='http://www.tfws.dynu.com'>TFWS Scripts</a></font>";
    
  
?>

[/code]
Now.. What do I put in mysql database. I assume that in table pm i put a field trash. Ok.. so i did. what are the values I should put. what is the default. after that, what should i change in delpm.php??? PLEASE PLEASE HELP!!!!! PLEEAAAASE! thanks for that much info so for though.
Link to comment
https://forums.phpfreaks.com/topic/6515-please-help/#findComment-24035
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.