Ja det er korrekt mcgoat - jeg har en gæstebog på min side.
og her er scriptet jeg har bruger
<?php require_once('../Connections/guestbook.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "sign_guestbook")) {
$insertSQL = sprintf("INSERT INTO guestbook (navn, email, tekst, dato) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['navn'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['tekst'], "text"),
GetSQLValueString($_POST['dato'], "date"));
mysql_select_db($database_guestbook, $guestbook);
$Result1 = mysql_query($insertSQL, $guestbook) or die(mysql_error());
$insertGoTo = "show_guestbook.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$colname_rsDato = "1";
if (isset($_GET['dato'])) {
$colname_rsDato = (get_magic_quotes_gpc()) ? $_GET['dato'] : addslashes($_GET['dato']);
}
mysql_select_db($database_guestbook, $guestbook);
$query_rsDato = sprintf("SELECT dato FROM guestbook WHERE dato = '%s'", $colname_rsDato);
$rsDato = mysql_query($query_rsDato, $guestbook) or die(mysql_error());
$row_rsDato = mysql_fetch_assoc($rsDato);
$totalRows_rsDato = mysql_num_rows($rsDato);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="POST" name="sign_guestbook" id="sign_guestbook">
<table width="400" border="0" cellpadding="2" cellspacing="2" class="layout">
<tr class="top">
<td colspan="2"> </td>
</tr>
<tr valign="top">
<td>Navn:</td>
<td><input name="navn" type="text" id="navn" size="50"></td>
</tr>
<tr valign="top">
<td>Email:</td>
<td><input name="email" type="text" id="email" size="50"></td>
</tr>
<tr valign="top">
<td>Hilsen:</td>
<td><textarea name="tekst" cols="50" rows="7" id="tekst"></textarea></td>
</tr>
<tr valign="top">
<td> </td>
<td><input name="dato" type="hidden" id="dato" value="<?php echo $row_rsDato['dato']; ?>"></td>
</tr>
<tr>
<td class="bottom"> </td>
<td class="bottom"><input type="submit" name="Submit" value="Skriv i gæstebog"></td>
</tr>
</table>
<p> </p>
<input type="hidden" name="MM_insert" value="sign_guestbook">
</form>
</body>
</html>
<?php
mysql_free_result($rsDato);
?>