<?php require_once('Connections/Buchregal.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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 buch (Buchtitel, Autor, Verlag, ISBN, Datum, Seiten, CD, Preis, Text) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Buch'], "text"),
                       GetSQLValueString($_POST['Autor'], "text"),
                       GetSQLValueString($_POST['Verlag'], "text"),
                       GetSQLValueString($_POST['ISBN'], "text"),
                       GetSQLValueString($_POST['Datum'], "date"),
                       GetSQLValueString($_POST['Seiten'], "int"),
                       GetSQLValueString($_POST['CD'], "int"),
                       GetSQLValueString($_POST['Preis'], "double"),
                       GetSQLValueString($_POST['Text'], "text"));

  mysql_select_db($database_Buchregal, $Buchregal);
  $Result1 = mysql_query($insertSQL, $Buchregal) or die(mysql_error());
}

mysql_select_db($database_Buchregal, $Buchregal);
$query_Recordset1 = "SELECT * FROM buch";
$Recordset1 = mysql_query($query_Recordset1, $Buchregal) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php require_once('Connections/Buchregal.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];

$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_Recordset1") == false && 
        stristr($param, "totalRows_Recordset1") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);

$queryString_Recordset2 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_Recordset2") == false && 
        stristr($param, "totalRows_Recordset2") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_Recordset2 = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_Recordset2 = sprintf("&totalRows_Recordset2=%d%s", $totalRows_Recordset2, $queryString_Recordset2);
?><!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=iso-8859-1" />
<title>Unbenanntes Dokument</title>
<style type="text/css">
<!--
.Stil1 {
	font-size: 36px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
	color: #6A6000;
}
.Stil5 {
	font-size: 10px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	line-height: 15px;
}
a:link {
	color: #2D7EAB;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #2D7EAB;
}
a:hover {
	text-decoration: underline;
}
a:active {
	text-decoration: none;
}
.Stil9 {	color: #FFFFFF;
	font-weight: bold;
	font-size: 12px;
}
.Stil9 {font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 15px; font-weight: bold; }
.Stil11 {font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 15px; font-weight: bold; color: #000000; }
.Stil14 {
	font-weight: bold;
	color: #000000;
	font-size: 10px;
}
.Stil16 {line-height: 15px; font-weight: bold; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
-->
</style>
</head>

<body>
<table width="100%" border="0" cellpadding="5" cellspacing="0">
  <tr>
    <td width="839" height="70" bgcolor="#FFE300"><div align="center" class="Stil1">B&uuml;chershop</div></td>
  </tr>
</table>
<p>&nbsp;</p>
<table width="100%" border="0" cellspacing="0" cellpadding="10">
  <tr>
    <td bgcolor="#2D7EAB" class="Stil5"><div align="center" class="Stil9">VERWALTUNG DER DATENBANK </div></td>
  </tr>
  <tr>
    <td bgcolor="#D0E1EB"><form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
      <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr>
          <td width="200" class="Stil11"><span class="Stil14">Buchtitel</span></td>
          <td colspan="2"><label>
            <input name="Buch" type="text" id="Buch" size="80" />
          </label></td>
        </tr>
        <tr>
          <td class="Stil16">Autor</td>
          <td colspan="2"><label>
            <input name="Autor" type="text" id="Autor" size="15" />
          </label></td>
        </tr>
        <tr>
          <td class="Stil16">Verlag</td>
          <td colspan="2"><label>
            <input name="Verlag" type="text" id="Verlag" size="15" />
          </label></td>
        </tr>
        <tr>
          <td class="Stil16">ISBN</td>
          <td colspan="2"><label>
            <input name="ISBN" type="text" id="ISBN" size="17" />
          </label></td>
        </tr>
        <tr>
          <td class="Stil16">Datum</td>
          <td colspan="2"><label>
            <input name="Datum" type="text" id="Datum" size="10" />
          </label></td>
        </tr>
        <tr>
          <td class="Stil16">Seiten</td>
          <td colspan="2"><label>
            <input name="Seiten" type="text" id="Seiten" size="3" />
          </label></td>
        </tr>
        <tr>
          <td class="Stil16">CD</td>
          <td colspan="2"><label>
            <input name="CD" type="text" id="CD" size="1" />
          </label></td>
        </tr>
        <tr>
          <td class="Stil16">Preis</td>
          <td colspan="2"><label>
            <input name="Preis" type="text" id="Preis" size="5" />
          </label></td>
        </tr>
        <tr>
          <td class="Stil16">Text</td>
          <td colspan="2"><label>
            <textarea name="Text" cols="80" rows="5" id="Text"></textarea>
          </label></td>
        </tr>
        <tr>
          <td height="20" class="Stil16">&nbsp;</td>
          <td height="20"><label>
            <input type="submit" name="button" id="button" value="Senden" />
          </label></td>
          <td><label>
            <input type="reset" name="button2" id="button2" value="Zur&uuml;cksetzen" />
          </label></td>
        </tr>
      </table>
        <input type="hidden" name="MM_insert" value="form1" />
    </form>
    </td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>