to jest plik z formularzem:
Kod
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-language" content="pl">
<title>Dodawanie kategori </title>
</head>
<body>
Dodaj nowa kategorie:<br>
<form action="dodaj.php" method="post">
<input type="text" name="kategoria" size="30" maxlength="30">
<input type="submit" name="submit" value="wyslij">
</form>
</body>
</html>
to jest plik dodaj:
Kod
<?php
require_once("connect.inc");
$query = "INSERT INTO kategorie VALUES (NULL,'$kategoria')";
$query_result = mysql_query ($query);
if ($query_result)
{
echo '<b><font color="green">Kategoria zostala dodana!</font></b>';
} else {
echo '<b><font color="red">Kategoria NIE zostala dodana!</font></b>';
}
mysql_close();
?>
a to plik connect:
Kod
<?
DEFINE (DB_USER, "root");
DEFINE (DB_PASSWORD, "fiufiu");
DEFINE (DB_HOST, "localhost");
DEFINE (DB_NAME, "katalog");
//polaczenie MySQL
$db_connection = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
mysql_select_db(DB_NAME);
?>
noi to tyle