Jump to content

Deleting a message


JayLewis

Recommended Posts

I want a button to delete each message in you inbox wen clicked. im using this that doesn't work, because i coded it :P

 

<input type='submit' name='Delete' value='Delete' onClick=\"self.location='?del=$get->id'\">

 

Full Code

<?php 
session_start(); 
include "includes/db_connect.php";
include "includes/functions.php";
include"includes/smile.php";
logincheck();

echo "<link href=includes/in.css rel=stylesheet type=text/css> ";

$username = $_SESSION['username'];
$mysql=mysql_query("SELECT * FROM users WHERE username='$username'");
$fetch=mysql_fetch_object($mysql);

/////START DELETE THERE MSG
if (strip_tags($_POST['Accept_get_away']) && $_GET['accept'] == "oc"){
$oc_id = $_GET['oc_id'];
$abc = mysql_num_rows(mysql_query("SELECT * FROM get_away WHERE id='$oc_id' AND invite_get='$username'"));

if ($abc != "0"){
if ($fetch->get_away == "1"){ echo "Your in a Getaway"; }elseif ($fetch->get_away == "0"){
if ($fetch->get_away_time > time()){ echo "You cant do anouther Getaway yet."; }elseif ($fetch->get_away_time < time()){




mysql_query("UPDATE get_away SET person='$username' WHERE id='$oc_id'");

mysql_query("UPDATE users SET get_away='1' WHERE username='$username'");
echo "You are now in that Getaway";
}
}}
}

if (strip_tags($_POST['Accept_marriage'] && $_GET['accept'] == "marry")){
$marriewhom = strip_tags($_GET['marrie_who']);

$lyegdfgdfgdf = mysql_num_rows(mysql_query("SELECT * 
FROM `married` 
WHERE `starter` = '$username'
OR `other` = '$username' AND `done` = '1'"));
if ($lyegdfgdfgdf != "0"){
echo "Your already married.";
}elseif ($lyegdfgdfgdf == "0"){



mysql_query("UPDATE married SET done='1' WHERE starter='$marriewhom' AND other='$username'");

echo "Congratulations, you have been officially married with $marriewhom!";
//}else{
//echo "Hmm, for some reason you haven't been asked to marry $marriewhom";
//}
}}

if (strip_tags($_POST['join_crew']) && strip_tags($_POST['invite_crew'])){
$invite_crew = strip_tags($_POST['invite_crew']);

if ($invite_crew == "1"){
$shit=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));


$true=mysql_fetch_object(mysql_query("SELECT * FROM crews WHERE id='$shit->crew_invite'"));
$numba = mysql_num_rows(mysql_query("SELECT * FROM users WHERE crew='$true->crew'"));
if ($numba >= $true->size){
echo "Sorry that crew is currently full, please wait untill there is space for you.";
}else{


mysql_query("DELETE FROM inbox WHERE event_id='$shit->crew_invite'");
mysql_query("UPDATE users SET crew='$true->name', crew_invite='0'  WHERE username='$username'");
echo "You are now in that crew";
}}

}
if (strip_tags($_POST['Accept_OC'])){
$oc_id=strip_tags($_POST['oc_id']);
if (strip_tags($_POST['place']) == "we"){
$use="we_inv";
$a="we";
$query= "SELECT * FROM oc WHERE we_inv='$username' AND id='$oc_id'";
}elseif (strip_tags($_POST['place']) == "ee"){
$use="ee_inv";
$a="ee";
$query= "SELECT * FROM oc WHERE ee_inv='$username' AND id='$oc_id'";

}elseif (strip_tags($_POST['place']) == "driver"){
$use="driver_inv";
$a="driver";
$query= "SELECT * FROM oc WHERE driver_inv='$username' AND id='$oc_id'";
}

$round=mysql_query($query);
$check=mysql_num_rows($round);
if ($check != "0"){
echo "You are now in that OC";
mysql_query("UPDATE `oc` SET `$a`='$username' WHERE `id`='$oc_id'");
mysql_query("UPDATE `users` SET `oc`='1' WHERE `username`='$username'");
}
}
if (strip_tags($_POST['Yes_street'])){
$race_id=strip_tags($_POST['race_id']);
if ($fetch->street != "0"){ echo "Your in a race."; }elseif ($fetch->street == "0"){

if ($fetch->last_race >= time()){ echo "You cant do anouther race yet."; }elseif ($fetch->last_race < time()){

$aa=mysql_query("SELECT * FROM street WHERE id='$race_id' AND op_invite='$username'");
$check=mysql_num_rows($aa);
$shit=mysql_fetch_object($aa);
if ($check == "0"){
echo "There has been an error. Get the Leader to resend the invite.";
}elseif ($check != "0"){
if ($shit->prize == "Money"){
$new_money=$fetch->money - $shit->prize_win;
if ($fetch->money < $shit->prize_win){
echo "You cant afford this!";
}elseif ($fetch->money >= $shit->prize_win){

mysql_query("UPDATE users SET street='1', money='$new_money' WHERE username='$username'");
mysql_query("UPDATE street SET op_username='$username' WHERE id='$shit->id'");
echo "Your now in that street race.";
}
}else{

mysql_query("UPDATE street SET op_username='$username' WHERE id='$shit->id'");
mysql_query("UPDATE users SET street='1' WHERE username='$username'");
echo "Your now in that street race.";

}}}





}}



echo "";










if ($_GET['del']){
$del=$_GET['del'];
$checker = mysql_query("SELECT * FROM inbox WHERE to='$username' AND id ='$del' ");
$rows=mysql_num_rows($checker);
if ($rows > "0"){
echo "Message deleted";
mysql_query("DELETE FROM inbox WHERE id='$del'");
}}////END DELETE THERE MSG
if (strip_tags($_POST['Dall'])){
mysql_query("DELETE FROM inbox WHERE saved='0' AND to='$username'");
echo "<center><b>All messages deleted</b></center><br>";
}
if (strip_tags($_POST['D_s'])){
foreach($_POST['radio'] as $value) {
   $count++;
mysql_query("DELETE FROM inbox WHERE id='$value'");
} 
echo "$count messages deleted<br>";
}




echo "<center>";
$mysql1 = mysql_query("SELECT * FROM `inbox` WHERE `to`='$username' AND `saved` ='0' ORDER by date DESC");
$num_rows =mysql_num_rows($mysql1);
if ($num_rows == "0"){
echo "You have no mail.";
}else{
while($get = mysql_fetch_object($mysql1)){
$t++;
$n++;
echo "
<table align=center border=\"1px\" width=474 height=24 class=\"tdcell\" style=\"border-style:solid; border-width:1px\">
<tr>

<td height=\"18\" width=\"464\" class=\"tdcell\" style=\"background-image: url('images/menubg.jpg')\">
	<center>From:<b><a href='profile.php?viewuser=$get->from'>$get->from</a></b> On: <b>$get->date</b></a></td>
	</tr>
<tr>

<td height=18 width=464 class=tdcell style=\"background-image: url('images/menubg2.jpg')\">
	".replace($get->message)."<br><br>
<input type='submit' name='Delete' value='Delete' onClick=\"self.location='?del=$get->id'\"></a></td>
	</tr>
</table>

            
          </td>
        </tr>
      </table></td>
  </tr>
</table><br>
";



}}
echo "</form>";
mysql_query("UPDATE `inbox` SET `read`='1' WHERE `to`='$username'");
echo "</center>";

?>

<link rel="stylesheet" href="./styles.css" type="text/css">

Link to comment
https://forums.phpfreaks.com/topic/46189-deleting-a-message/
Share on other sites

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.