dodaj.html
Kod
<html>
<head>
<title>Dodawanie danych</title>
</head>
<body>
<h2>Dodawanie newsów</h2>
<form action="polaczenie.php" method="post">
Treść:<br>
<input type=text name="tresc" size=300><br>
Autor:<br>
<input type=text name="autor" size=15><br>
Data dodania <b>rrrr-mm-dd</b>:<br>
<input type=text name="data" size=30><br><br>
<input type=submit value="dodaj dane"><br>
</form>
</body>
</html>
<head>
<title>Dodawanie danych</title>
</head>
<body>
<h2>Dodawanie newsów</h2>
<form action="polaczenie.php" method="post">
Treść:<br>
<input type=text name="tresc" size=300><br>
Autor:<br>
<input type=text name="autor" size=15><br>
Data dodania <b>rrrr-mm-dd</b>:<br>
<input type=text name="data" size=30><br><br>
<input type=submit value="dodaj dane"><br>
</form>
</body>
</html>
a następnie
polaczenie.php
Kod
<html>
<head>
<title> Baza danych </title>
</head>
<body>
<?
$baza = "db859***";
$tabela = "newsy";
$polaczenie = mysql_connect("mysql2.yoyo.pl", "db859***", "********");
$wybierz = mysql_select_db($baza, $polaczenie);
$wstaw = "INSERT INTO $tabela VALUES (tresc, autor, data)";
$rezultat = mysql_query($wstaw, $polaczenie);
if ($rezultat) {
echo "<h2>Do tabeli zostały dodane następujące dane:</h2><br>
<b>Treść:</b> <i>$tresc</i><br>
<b>Autor:</b> <i>$autor</i><br>
<b>Data dodania:</b> <i>$data</i><br>";
}
else {
echo "<h2>Do tabeli nie dodano danych</h2>";
}
?>
</body>
</html>
<head>
<title> Baza danych </title>
</head>
<body>
<?
$baza = "db859***";
$tabela = "newsy";
$polaczenie = mysql_connect("mysql2.yoyo.pl", "db859***", "********");
$wybierz = mysql_select_db($baza, $polaczenie);
$wstaw = "INSERT INTO $tabela VALUES (tresc, autor, data)";
$rezultat = mysql_query($wstaw, $polaczenie);
if ($rezultat) {
echo "<h2>Do tabeli zostały dodane następujące dane:</h2><br>
<b>Treść:</b> <i>$tresc</i><br>
<b>Autor:</b> <i>$autor</i><br>
<b>Data dodania:</b> <i>$data</i><br>";
}
else {
echo "<h2>Do tabeli nie dodano danych</h2>";
}
?>
</body>
</html>
I po wpisaniu jakichś danych pokazuje mi komunikat że dodano do bazy, jednak wyświetla:
Treść:
Autor:
Data:
I nie pokazuje co takiego wstawiło, po czym w bazie także nic nie ma. Jak to zmienić?
Z góry dziękuje i pozdrawiam.