<?
include "check.php";
include "forb.php";
$q1 = mysql_query("SELECT * FROM brugere WHERE brugernavn = '$_SESSION[Brugernavn]'");
$se = mysql_fetch_array($q1);
$q3 = mysql_query("SELECT * FROM koebte_t WHERE id = '$_GET[id]' AND ejer = '$_SESSION[Brugernavn]'");
$antal = mysql_num_rows($q3);
$q2 = mysql_query("SELECT * FROM koebte_t WHERE id = '$_GET[id]'");
$vis = mysql_fetch_array($q2);
if($se[smid_ting] == '1'){
if($vis[kaeledyr] == 'ja'){
print "FEJL NR. 1239";
}else{
if($antal == '0'){
print "FEJL NR. 1123";
}else{
$billede = $vis[billede];
$dato = date("d/m h:i:s");
mysql_query("DELETE FROM koebte_t WHERE id = '$_GET[id]'");
mysql_query("INSERT INTO smid_ting (navn, billede, taget) VALUES ('$vis[navn]', '$billede', '0')") or die(mysql_error());
$q1 = mysql_query("SELECT * FROM smid_ting ORDER by id DESC LIMIT 1") or die(mysql_error());
while($se = mysql_fetch_array($q1)) {
mysql_query("INSERT INTO tagwall (af, dato, besked, farve) VALUES ('Robot', '$dato', '$_SESSION[Brugernavn] har smidt tingen <b>$vis[navn]</b>! Hvis du vil tage den, <a href=pick_up.php?id=$se[id]><u><b>Saml op!</u></b></a>', 'orange')") or die(mysql_error());
print "<meta http-equiv='refresh' content='0; url=tagwall.php'>";
print "<br/><br/>";
}
}}
}
?>