Hjælp med tagwall
Hej hvad er der galt her ?min db kode:
CREATE TABLE `tagwalls` (
`id_nr` tinyint(4) NOT NULL auto_increment,
`navn` varchar(30) NOT NULL default '',
`email` varchar(255) default '',
`hp` varchar(255) default '',
`tekst` varchar(255) NOT NULL default '',
`dato` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id_nr`)
) TYPE=MyISAM AUTO_INCREMENT=33 ;
Min kode:
<?php
include"db.php";
?>
<b>Tagwall</b>
<hr size="1" color="#000000">
<table width="500">
<tr>
<td>
<script language="javascript">
<!--
function check_form() {
if (document.submit.navn.value=="") {
alert("Udfyld navn");
return false;
} else if (document.submit.email.value=="") {
alert("Udfyld din email");
return false;
} else if (document.submit.tekst.value=="") {
alert("Du mangler at skrive en besked");
return false;
}
return true; }
function isInteger(streng) { var isOK = true;
if (streng.length==0) isOK = false; for (var i=0;i<streng.length;i++) {
if ((streng.charAt(i) < "0") || (streng.charAt(i) > "9")) isOK = false; } return (!isOK); }
//-->
</script>
<form method="post" action="<? $PHP_SELF ?>">
<b>Navn:</b></td><td><input type="text" name="navn" value="<?=$_COOKIE[$cookie["navn"] . "navn"];?>" size="20">
</td></tr>
<tr>
<td>
<b>Email:</b></td><td><input type="text" name="email" value="<?=$_COOKIE[$cookie["navn"] . "email"];?>" size="20">
</td></tr>
<tr>
<td>
<b>Hjemmeside:</b></td><td><input type="text" name="hp" value="<?=$_COOKIE[$cookie["navn"] . "hp"];?>" size="20">
</td></tr>
<tr>
<td>
<b>Besked:</b></td><td><textarea cols="20" rows="10" name="tekst"></textarea>
</td></tr>
<tr>
<td><input type="submit" value="Skriv besked" name="submit">
</td></tr>
<tr><td><br></td></tr>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
mysql_query("INSERT INTO tagwall (dato, navn, email, hp, tekst)
values(
'".date("Y-m-j H:i:s")."',
'".$_POST["navn"]."',
'".$_POST["email"]."',
'".$_POST["hp"]."',
'".$_POST["tekst"]."',)") or die (mysql_error());
setcookie($cookie["navn"] . "navn", $_POST["navn"], time()+$cookie["time"], $cookie["path"], $cookie["domain"], $cookie["secure"]);
setcookie($cookie["navn"] . "email", $_POST["email"], time()+$cookie["time"], $cookie["path"], $cookie["domain"], $cookie["secure"]);
setcookie($cookie["navn"] . "hp", $_POST["hp"], time()+$cookie["time"], $cookie["path"], $cookie["domain"], $cookie["secure"]);
header("Location: $_SERVER[PHP_SELF]");
}
?>
<?php
$conn = mysql_query("SELECT * FROM tagwall ORDER BY id DESC");
while ($rs = mysql_fetch_array($conn))
{
?>
<tr>
<td width="20%">Dato:</td>
<td width="80%"><?=format_date("l \\d\e\\n. j F Y - H:i", $rs["dato"]);?></td>
</tr>
<tr>
<td>Navn:</td>
<td>
<?php if (check_email($rs["email"])) {?>
<a title="<?=htmlspecialchars($rs["email"]);?>" href="mailto:<?=htmlspecialchars($rs["email"]);?>"><?=htmlspecialchars(wraptext($rs["navn"], 30));?></a>
<?php } else {?>
<a><?=htmlspecialchars(wraptext($rs["navn"], 30));?></a>
<?php }?>
</td>
</tr>
<tr>
<td>Hjemmeside:</td>
<td>
<?php if (hyperlinks($rs["hp"])) {?>
<a title="<?=$rs["hp"];?>" href="<?=$url;?>" target="_blank"><?=wraptext($rs["hp"], 20);?></a>
<?php } else {?>
Ikke udfyldt
<?php }?>
</td>
</tr>
<?php } ?>