witam
mam problem. strona php + mysql. po odświeżeniu strony do bazy dodawane są dane nawet jak w polach formularza nic nie ma. jak sobie z tym poradzić.
o to cały kod :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sklep</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="stmenu.js"></script></head>
<script language="javascript" type="text/javascript">
function go() {
location.href = "index.php?id="+document.getElementsByName("kategoria")[0].value;
}
</script>
<body>
<div id="main">
<div id="top" onclick="location.href='index.php'">
<div id="wyszukiwarka">
</div>
<div id="menu">
</div>
</div>
<div id="glowny">
<div id="dodawanie_kat">
<table>
<form method="POST">
<tr>
<td><b>Nazwa:</b> </td> <td><input type="text" name="nazwa"></td>
<td><b>Typ:</b> </td> <td> <input type="text" name="typ"></td>
<td><b>Kwota:</b> </td><td><input type="text" name="kwota"></td>
<td><input type="submit" value="Zatwierdz" name="zatwierdz"></td>
</tr>
</form>
</table>
<?php
include "define.php";
mysql_connect(serwer,login,haslo);
mysql_select_db(baza);
if (isset($_POST['zatwierdz']))
{
$nazwa =($_POST['nazwa']);
$typ = ($_POST['typ']);
$kwota =($_POST['kwota']);
mysql_query("INSERT INTO kategorie (nazwa, typ, kwota) VALUES ('".$nazwa."', '".$typ."', '".$kwota."');");
echo "g";
}
?>
</div>
</div
<div id="stopka_pasek">
<div id="stopka_left"><span class="bold">Projekt</span>© 2012/2013</div>
<div id="stopka_right">Created by <a href="http://www.onet.pl" target="_blink" class="stopka_link">Team</a></div>
</div>
</div>
</body>
</html>