Dette du mener? Dette er koden
<?php require_once('Connections/gjestebokkobling.php'); ?>
<?php require_once('Connections/gjestebokkobling.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO hilsen (tidsstempel, tittel, navn, tekst) VALUES (NOW() (%s, %s, %s)",
GetSQLValueString($_POST['tittel'], "text"),
GetSQLValueString($_POST['navn'], "text"),
GetSQLValueString($_POST['tekst'], "text"));
mysql_select_db($database_gjestebokkobling, $gjestebokkobling);
$Result1 = mysql_query($insertSQL, $gjestebokkobling) or die(mysql_error());
}
mysql_select_db($database_gjestebokkobling, $gjestebokkobling);
$query_hilsner = "SELECT DATE_FORMAT(tidsstempel,'%d/%m-%Y') AS 'dato', DATE_FORMAT(tidsstempel,'%H:%i) AS 'tid', tittel, navn, tekst FROM hilsen ORDER BY tidsstempel DESC ";
$hilsner = mysql_query($query_hilsner, $gjestebokkobling) or die(mysql_error());
$row_hilsner = mysql_fetch_assoc($hilsner);
$totalRows_hilsner = mysql_num_rows($hilsner);
$query_hilsner = "SELECT DATE_FORMAT(tidsstempel,'%d/%m-%y') AS 'dato', DATE_FORMAT(tidsstempel,'%H:%i') AS 'tid', tittel, navn, tekst FROM hilsen ORDER BY tidsstempel DESC";
$hilsner = mysql_query($query_hilsner, $gjestebokkobling) or die(mysql_error());
$row_hilsner = mysql_fetch_assoc($hilsner);
$totalRows_hilsner = mysql_num_rows($hilsner);
$query_hilsner = "SELECT DATE_FORMAT(tidsstempel,'%d/%m-%y') AS 'dato', DATE_FORMAT(tidsstempel,'%H:%i') AS 'tid', tittel,navn,tekst FROM hilsen ORDER BY tidsstempel DESC";
$hilsner = mysql_query($query_hilsner, $gjestebokkobling) or die(mysql_error());
$row_hilsner = mysql_fetch_assoc($hilsner);
$totalRows_hilsner = mysql_num_rows($hilsner);
$query_hilsner = "SELECT DATE_FORMAT(tidsstempel,'%d/%m-%Y') AS 'dato' , DATE_FORMAT(tidsstempel,'%H:%i') AS 'tid', tittel, navn, tekst FROM hilsen ORDER BY tidsstempel DESC ";
$hilsner = mysql_query($query_hilsner, $gjestebokkobling) or die(mysql_error());
$row_hilsner = mysql_fetch_assoc($hilsner);
$totalRows_hilsner = mysql_num_rows($hilsner);
?>
<!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" />
<title>gjestebokprosjekt</title>
</head>
<body>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Tittel:</td>
<td><input type="text" name="tittel" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Navn:</td>
<td><input type="text" name="navn" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" valign="top">Tekst:</td>
<td><textarea name="tekst" cols="50" rows="5"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Send hilsen" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
<hr />
<p> </p>
<?php do { ?>
<h3> <?php echo $row_hilsner['tittel']; ?></h3>
<p><strong>Avsender:</strong> <?php echo $row_hilsner['navn']; ?></p>
<p><strong>Dato</strong>:<?php echo $row_hilsner['dato']; ?>(<?php echo $row_hilsner['tid']; ?>)</p>
<p> <?php echo $row_hilsner['tekst']; ?></p>
<?php } while ($row_hilsner = mysql_fetch_assoc($hilsner)); ?>
</body>
</html>
<?php
mysql_free_result($hilsner);
?>
SELECT DATE_FORMAT(tidsstempel,'%d/%m-%Y') AS 'dato', DATE_FORMAT(tidsstempel,'%H:%i) AS 'tid', tittel, navn, tekst
FROM hilsen
ORDER BY tidsstempel DESC
Dette er koden for gjesteboken