Hi @ll,
ich habe ein Problem mit einem Eingabeformular.
Ich habe eine HTML-Datei gebastelt, in dem das Eingabeformular selbst drin ist und eine PHP-Datei, in der die Datenbankprozedur drin ist.
Die HTML-Datei sieht folgendermassen aus:
PHP-Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>MOE-Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="blau.css"/>
</head>
<body>
[img]titel_z.gif[/img]
<table class="inhalt" border="0">
<tr>
<td valign="top" align="left" width="5"></td>
<td valign="top" align="left" style="padding-top: 15px;"><h3>Countries - Enter a new record</h3></td>
</tr>
</table>
<table class="inhalt" border="0">
<form action ="Countries_n.php" method = "post">
<tr><td>Countrys name: <td> <input name = "pa"> Example: Bulgaria</tr>
<tr><td>ISO short: <td> <input name = "pb"> Example: BG</tr>
<tr><td>ISO long: <td> <input name = "pc"> Example: BUL</tr>
<tr><td>Date of independence: <td> <input name = "pd"> Example: 19900101</tr>
<tr><td>Date of inception of the first free constitution: <td> <input name = "pe"> Example: 19900301</tr>
<tr><td>Date of the first free election: <td> <input name = "pf"> Example: 19900815</tr>
</table>
<input type = "submit">
<input type = "reset">
</form>
</body>
</html>
Die PHP-Datei sieht so aus:
PHP-Code:
<html>
<body>
<?
include "security/access.inc";
$db = mysql_connect ($host,$user,$pw)
or exit ("Keine Verbindung hergestellt!");
mysql_select_db ("moe",$db)
or exit ("Datenbank nicht geöffnet");
$sqlbef = "insert into Countries (Country, ISO_short, ISO_long, Independence, First_free_constitution, First_free_election)
values ('$pa', '$pb', '$pc', '$pd', '$pe', '$pf')";
$sqlerg = mysql_query($sqlbef, $db);
IF ($sqlerg)
ECHO "Record entry successful";
ELSE
ECHO "Rechord entry NOT successful";
?>
</body>
</html>
Die PHP-Datei funktioniert anscheinend. Ich habe das SQL-Skript gesondert geprueft und es funktioniert. Ersetzt man die Variablen durch feste Werte, werden diese ebenfalls in die Datenbank geschrieben. Dies deutet zudem daraufhin, dass die Datenbankanbindung auch funktioniert.
Daher bleibt nur noch die HTML-Datei als Fehlerquelle. Ich vermute, dass es an den Namen in <input name ... > liegt.
Kann mir da bitte jemand von euch helfen?
Vielen Dank!
Gruss,
Der Verzweifelte
