warum funktioniert mein gaestebuch nicht? ich erhalte folgende fehlermeldung beim aufruf von index.php im internet explorer:
Notice: Undefined index: submit in c:\program files\easyphp1-7\www\guestbook_test\submit.php on line 2
-----------------------------
das formular index.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="guestbook" method="post" action="submit.php">
<p>name
<input name="name" type="text" id="name" size="23" maxlength="50">
</p>
<p>
email
<input name="email" type="text" id="email" size="23" maxlength="50">
</p>
<p>
message
<textarea name="text" cols="55" rows="7" id="text"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<p> </p>
</form>
</body>
</html>
-----------------------
submit.php:
<?php
if($_POST['submit'])
{
$db = mysql_connect('localhost','root','')
or die(mysql_errno().' : '.mysql_error());
mysql_select_db('gbtest')
or die(mysql_errno().' : '.mysql_error());
$sql[addpost] = mysql_query("INSERT INTO guestbook (name, email, message, date)
VALUES ('$_POST[name]','$_POST[email]','$_POST[message]',time())");
mysql_close($db);
echo "Thanks ".$_POST['name']." your message has been added\n";
}
?>
----------------
die struktur der datenbank gbtest, tabelle guestbook:
# phpMyAdmin SQL Dump
# version 2.5.3
# http://www.phpmyadmin.net
#
# Host: localhost
# Erstellungszeit: 04. März 2005 um 10:27
# Server Version: 4.0.15
# PHP-Version: 4.3.3
#
# Datenbank: `gbtest`
#
# --------------------------------------------------------
#
# Tabellenstruktur für Tabelle `guestbook`
#
CREATE TABLE `guestbook` (
`id` int(10) NOT NULL auto_increment,
`name` varchar(50) default NULL,
`email` varchar(50) default NULL,
`message` text,
`date` varchar(10) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
#
# Daten für Tabelle `guestbook`
#
Notice: Undefined index: submit in c:\program files\easyphp1-7\www\guestbook_test\submit.php on line 2
-----------------------------
das formular index.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="guestbook" method="post" action="submit.php">
<p>name
<input name="name" type="text" id="name" size="23" maxlength="50">
</p>
<p>
<input name="email" type="text" id="email" size="23" maxlength="50">
</p>
<p>
message
<textarea name="text" cols="55" rows="7" id="text"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<p> </p>
</form>
</body>
</html>
-----------------------
submit.php:
<?php
if($_POST['submit'])
{
$db = mysql_connect('localhost','root','')
or die(mysql_errno().' : '.mysql_error());
mysql_select_db('gbtest')
or die(mysql_errno().' : '.mysql_error());
$sql[addpost] = mysql_query("INSERT INTO guestbook (name, email, message, date)
VALUES ('$_POST[name]','$_POST[email]','$_POST[message]',time())");
mysql_close($db);
echo "Thanks ".$_POST['name']." your message has been added\n";
}
?>
----------------
die struktur der datenbank gbtest, tabelle guestbook:
# phpMyAdmin SQL Dump
# version 2.5.3
# http://www.phpmyadmin.net
#
# Host: localhost
# Erstellungszeit: 04. März 2005 um 10:27
# Server Version: 4.0.15
# PHP-Version: 4.3.3
#
# Datenbank: `gbtest`
#
# --------------------------------------------------------
#
# Tabellenstruktur für Tabelle `guestbook`
#
CREATE TABLE `guestbook` (
`id` int(10) NOT NULL auto_increment,
`name` varchar(50) default NULL,
`email` varchar(50) default NULL,
`message` text,
`date` varchar(10) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
#
# Daten für Tabelle `guestbook`
#
Kommentar