
Member
|
Hi, i need a help from you on how to create a delete message/topic from the read_pm.php.
I tried using the forum php code for delete topic but it doesnt work. Can you help me? I tried this so far.
<?php
//This page let delete a topic
include('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
<title>Delete a topic - <?php echo htmlentities($dn1['title'], ENT_QUOTES, 'UTF-8'); ?> - <?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?> - Forum</title>
<script type="text/javascript">
<!--
function FP_preloadImgs() {//v1.0
var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}
function FP_swapImg() {//v1.0
var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
elm.$src=elm.src; elm.src=args[n+1]; } }
}
function FP_getObjectByID(id,o) {//v1.0
var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
return null;
}
// -->
</script>
</head>
<body onload="FP_preloadImgs(/*url*'default/images/buttonAB.jpg',/*url*'default/images/buttonAC.jpg')">
<div class="header">
<a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Forum" /></a>
</div>
<div class="content">
<?php
if(isset($_SESSION['email']))
{
if(isset($_GET['id']))
{
$id = intval($_GET['id']);
$dn1 = mysql_fetch_array(mysql_query('select count(p.id) as nb1, p.title, p.username from pm as p, users as u where p.id="'.$id.'" and p.id2=1 and u.id=p.id'));
if($dn1['nb1']>0)
{
?>
<?php
$nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"'));
$nb_new_pm = $nb_new_pm['nb_new_pm'];
?>
<div class="box">
<div class="box_left">
<a href="<?php echo $url_home; ?>">Home</a> > <a href="list_pm.php;">"<?php echo htmlentities($dn1['username'], ENT_QUOTES, 'UTF-8'); ?></a> > <a href="read_pm.php?id=<?php echo $id; ?>"><?php echo htmlentities($dn1['title'], ENT_QUOTES, 'UTF-8'); ?></a> > Delete Message
</div>
<div class="box_right">
<a href="list_pm.php">Your messages(<?php echo $nb_new_pm; ?>)</a> - <a href="profile.php?id=<?php echo $_SESSION['email']; ?>"><?php echo htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8'); ?></a> (<a href="connexion.php">Logout</a>)
</div>
<div class="clean"></div>
</div>
<?php
if(isset($_POST['confirm']))
{
if(mysql_query('delete from topics where id="'.$id.'"'))
{
?>
<div class="message">The topic have successfully been deleted.<br />
<?php
}
else
{
echo 'An error occured while deleting the topic.';
}
}
else
{
?>
<form action="delete.php?id=<?php echo $id; ?>" method="post">
Are you sure you want to delete this topic?
<input type="hidden" name="confirm" value="true" />
<input type="submit" value="Yes" /> <input type="button" value="No" onclick="javascript:history.go(-1);" />
</form>
<?php
}
?>
</div>
<div class="foot"><a href="index.php">
<img id="img1" alt="Home" fp-style="fp-btn: Braided Row 1; fp-font-style: Bold" fp-title="Home" height="24" onmousedown="FP_swapImg(1,0,/*id*'img1',/*url*'default/images/buttonAC.jpg')" onmouseout="FP_swapImg(0,0,/*id*'img1',/*url*'default/images/buttonAA.jpg')" onmouseover="FP_swapImg(1,0,/*id*'img1',/*url*'default/images/buttonAB.jpg')" onmouseup="FP_swapImg(0,0,/*id*'img1',/*url*'default/images/buttonAB.jpg')" src="default/images/buttonAA.jpg" style="border: 0" width="120"></a></div>
</body>
</html>
<?php
}
else
{
echo '<h2>You don\'t have the right to delete this topic.</h2>';
}
}
else
{
echo '<h2>The topic you want to delete doesn\'t exist.</h2>';
}
}
else
{
echo '<h2>The ID of the topic you want to delete is not defined.</h2>';
}
?>
|