Slet gæstebog besked i brugersystem
Hej i Eksperter:D..Jeg har et problem med et community..i det community kan man skrive i hinnadens gæstebøger,Og nu kommer jeg til spørgsmålet,Hvordan kan jeg lave en "slette-funktion" så at brugeren kan slette deres beskeder? her er mit script (som ikke virker): Hvordan får jeg det til at virke?<?php
include("menu.php");
?>
<?php
include_once("connect.php");
$db_profil = mysql_query("select * from brugere where brugernavn = '$_GET[b]'");
$profil = mysql_fetch_array($db_profil);
if($_GET['admin'] == "1"){
if($_SESSION['Rang'] == "Admin"){
mysql_query("UPDATE brugere SET status= '". mktime() ."' WHERE brugernavn = '$_SESSION[brugernavn]'");
mysql_query("update brugere set Rang = 'Admin' where id = '$_GET[bruger]'");
print "Brugeren blev gjort til admin!";
}
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="http://www.mvf.frac.dk/sty1e2.css" type="text/css" />
<style type="text/css">
<!--
.style3 {font-size: large}
-->
</style>
</head>
<body>
<table width="100%" border="0">
<tr>
<td width="253" height="164" valign="top"><?php if($profil['billede'] != ""){ ?>
<a href="<?php print $profil['billede'] ?>"><img src="<?php print $profil['billede'] ?>" width="100" height="100" border="0"></a>
<?php }else{ ?>(Intet billede!)<?php } ?></td>
<td width="732" valign="top"><div align="left">
<table width="100%" border="0">
<tr>
<td width="14%">Brugernavn: </td>
<td width="28%"><?php print $profil['brugernavn'] ?></td>
<td width="58%"><span class="style3">Point: <?php print $profil['point'] ?> </span></td>
</tr>
<tr>
<td>Navn:</td>
<td><?php print $profil['navn'] ?></td>
<td> </td>
</tr>
<tr>
<td>Køn:</td>
<td><?php print $profil['kon'] ?></td>
<td> </td>
</tr>
<tr>
<td>Civilstatus</td>
<td><?php print $profil['civilstatus'] ?></td>
<td> </td>
</tr>
<tr>
<td>Alder:</td>
<td><?php print $profil['alder'] ?> år.</td>
<td> </td>
</tr>
<tr>
<td>Fritid:</td>
<td><?php print $profil['fritid'] ?></td>
<td> </td>
</tr>
<tr>
<td>Landsdel:</td>
<td><?php print $profil['landsdel'] ?></td>
<td>Status:<?php
session_start();
include_once("connect.php");
$online = mysql_query("SELECT * FROM brugere WHERE brugernavn = '[brugernavn]'");
while($row = mysql_fetch_array($online))
{
print "Denne profil er:";
if($row['status']>mktime(-300))
{
print "Online";
}
else
{
print "Offline";
}
}
?>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table width="100%" height="154" border="1">
<tr>
<td height="111" valign="top"><?php print $profil['navn'] ?>´s Profil: </td>
</tr>
<tr>
<td valign="top"><a href="http://mvf.frac.dk/community/redigerProfil.php"></a></td>
</tr>
</table>
<br>
<p><strong>Gæstebog:</strong></p>
<table width="400" border="0">
<?php
$q2 = mysql_query("select * from taqwall where til = '$profil[id]'");
while($taqwall = mysql_fetch_array($q2)){
$q3 = mysql_query("DELETE FROM taqwall WHERE besked = '$_GET[id]'"); //slette funktion
?>
<tr>
<td width="195" bgcolor="#4D73C3"> </td>
<td width="195" bgcolor="#4D73C3">Dato: <?php print $taqwall['dato'] ?></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" bgcolor="#FFFFFF">Brugernavn: <?php print $taqwall['fra'] ?></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" bgcolor="#FFFFFF"><?php print $taqwall['besked'] ?> <a href="profil.php?slet=besked=<?php print $q3['id'] ?>">-slet </a></td> //knap til at slette beskeden
</tr>
<?php
}
?>
</table>
<p> <a href="taqwall.php?do=skriv&id=<?php print $profil['id'] ?>&bruger=<?php print $profil['brugernavn'] ?>">Skriv
i denne gæstebog! </a></p>
<?php
if($profil['brugernavn'] == $_SESSION['Brugernavn']){
?>
<p><a href="editprofil.php?id=<?php print $profil['id'] ?>">Ret profil!</a></p> //ret profil
<?php
}
?>
</body>
</html>
Database:
CREATE TABLE `nickin_taqwall` (
`id` int(11) NOT NULL auto_increment,
`til` varchar(255) NOT NULL default '',
`fra` varchar(255) NOT NULL default '',
`besked` varchar(255) NOT NULL default '',
`dato` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
Ps.Jeg er ikke den store php-nørd..
