P
PilotPirx
Auch ich hab hier das gleiche Problem wie Stefan. Das Formular funktioniert so eigentlich ganz gut. Der Wechsel auf die nächste Seite mit übergabe der ID funktioniert auch einwandfrei. Nur lässt sich nichts in der Datenbank speichern. Findet jemand den Fehler?
PHP Script erstes Formular (index.php).
und das zweite Formular (ort.php)
ich wäre um Hilfe sehr dankbar.
PHP Script erstes Formular (index.php).
PHP:
<?php require_once('Connections/seminar.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"] == "form1"))
{
$insertSQL = sprintf("INSERT INTO veranstaltung (id, veranstaltungstext, beschreibung) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['veranstaltungstext'], "text"),
GetSQLValueString($_POST['beschreibung'], "text"));
mysql_select_db($database_seminare, $seminar);
mysql_query($insertSQL, $seminar) or die(mysql_error());
$insertGoTo = "ort.php?id=" . mysql_insert_id ( $seminar );
if (isset($_SERVER['QUERY_STRING']))
{
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Seminar</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form method="post" name="seminarindex" action="ort.php">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Veranstaltungstext:</td>
<td><input type="text" name="veranstaltungstext" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Beschreibung:</td>
<td><input type="text" name="beschreibung" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input name="submit" type="submit" value="Datensatz einfügen"></td>
</tr>
</table>
<input name="id" type="hidden" id="id" value="seminarindex">
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
</form>
<p> </p>
</body>
</html>
und das zweite Formular (ort.php)
PHP:
<?php require_once('Connections/seminar.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;
}
$id .= $_POST['id'];
$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 veranstaltungsort (veranstaltung_id, straße, plz, ort) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['veranstaltung_id'], "int"),
GetSQLValueString($_POST['straße'], "text"),
GetSQLValueString($_POST['plz'], "int"),
GetSQLValueString($_POST['ort'], "text"));
mysql_select_db($database_seminare, $seminar);
mysql_query($insertSQL, $seminar) or die(mysql_error());
$insertGoTo = "ort.php";
if (isset($_SERVER['QUERY_STRING']))
{
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Veranstaltungsort</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form method="post" name="seminarort" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Straße:</td>
<td><input type="text" name="straße" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Plz:</td>
<td><input name="plz" type="text" size="32" maxlength="5"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Ort:</td>
<td><input type="text" name="ort" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><div align="center">
<input type="submit" value="Datensatz einfügen">
</div></td>
</tr>
</table>
<input name="hidden_id" type="hidden" id="id" value="seminarort">
<input type="hidden" name="veranstaltung_id" value="<?php echo $_GET['id']; ?>">
</form>
<p> </p>
</body>
</html>
ich wäre um Hilfe sehr dankbar.