<?php require_once('Connections/gb.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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE gaestebuch SET Name=%s, Email=%s, Comments=%s, Comments2=%s, `date`=%s WHERE ID=%s",
GetSQLValueString($_POST['Name'], "text"),
GetSQLValueString($_POST['Email'], "text"),
GetSQLValueString($_POST['Comments'], "text"),
GetSQLValueString($_POST['Comments2'], "text"),
GetSQLValueString($_POST['date'], "text"),
GetSQLValueString($_POST['ID'], "int"));
mysql_select_db($database_gb, $gb);
$Result1 = mysql_query($updateSQL, $gb) or die(mysql_error());
$updateGoTo = "gb_alle.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_gb = "-1";
if (isset($_GET['id'])) {
$colname_gb = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_gb, $gb);
$query_gb = sprintf("SELECT ID, Name, Email, Comments, Comments2 FROM gaestebuch WHERE ID = %s", $colname_gb);
$gb = mysql_query($query_gb, $gb) or die(mysql_error());
$row_gb = mysql_fetch_assoc($gb);
$totalRows_gb = mysql_num_rows($gb);
mysql_free_result($gb);
?>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td width="76" align="right" nowrap> </td>
<td width="317"> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Name:</td>
<td><input name="Name" type="text" value="<?php echo htmlentities($row_gb['Name']); ?>" size="50" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input name="Email" type="text" value="<?php echo $row_gb['Email']; ?>" size="50" /></td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap>Text:</td>
<td><textarea name="Comments" cols="50" rows="10"><?php echo $row_gb['Comments']; ?></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap>Kommentar:</td>
<td><textarea name="Comments2" cols="50" rows="10"><?php echo $row_gb['Comments2']; ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td>
<div align="left">
<input type="submit" value="Datensatz aktualisieren">
</div></td></tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="ID" value="<?php echo $row_gb['ID']; ?>">
</form>
<p> </p>