Jump to content


Photo

PLEASE HELP!!!


  • Please log in to reply
4 replies to this topic

#1 briguy9872

briguy9872
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 03 April 2006 - 09:55 PM

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
<?
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>";       
     
   
?>



#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 03 April 2006 - 11:05 PM

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.
follow me on twitter @PHPsycho

#3 briguy9872

briguy9872
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 04 April 2006 - 12:21 AM

[!--quoteo(post=361387:date=Apr 3 2006, 06:05 PM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Apr 3 2006, 06:05 PM) View Post[/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.

#4 khendar

khendar
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 04 April 2006 - 12:40 AM

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.

#5 briguy9872

briguy9872
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 05 April 2006 - 01:02 AM

[!--quoteo(post=361416:date=Apr 3 2006, 07:40 PM:name=khendar)--][div class=\'quotetop\']QUOTE(khendar @ Apr 3 2006, 07:40 PM) View Post[/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
<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>";
    
   
?>

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users