Witam, zaczynam dopiero moja prygode z PHP i MySQL i tu moje pytanie. W jaki sposob moge wyslac za pomoca formularza ane do bazy MySQL? Napisalem juz jakis kod, ale nie chce on wysylac danych. PRosilbym o sprawdzenie co musze zmienic.
formularz do zbierania danych
<html>
<head>
<title>Wysylanie Newsow</title>
</head>
<body>
<?
include 'config.php';
?>
<form name = "newsy"
action = "http://127.0.0.1/~php/submit.php"
method = "POST"
>
<table>
<tr>
<td>Tytul</td>
<td><input type="text" name="tytul"></td>
</tr>
<tr>
<td>Tresc Newsa</td>
<td><input type="text" name="tresc"></td>
</tr>
<tr>
<td><input type="submit" value="Wyślij"></td>
</table>
</form>
</body>
</html>
plik wysylajace dane
<html>
<head>
<title>Wyslanie Newsa</title>
</head>
<body>
<?
include 'config.php';
if ($tytul == '' or
empty($tytul) or
$tresc == '' or
empty($tresc)) { echo "<html>n<head>n<title>Blad</title>n</head>nn<body><h1 align="center
">Blad</h1>n<p>Nie wypelniles pola <b>Tytuł</b> i/lub <b>TRESC</b></p>"; echo "<a href="java script
:history
.back
()">Powrot do formularza</a></body></html>"; }
$query = "insert into News values ('$tytul', '$tresc')";
?>
Dziękujemy za dodanie ogloszenia. Kliknij <a href="index.php">tutaj</a> aby zobaczyć stronę główną.
</body>
</html>