Shiko kodin php :
Kodi PHP:
<?
mysql_connect("localhost", "username", "password");
mysql_select_db("emri_i_database");
if (!isset($submit)) {
$sql = "SELECT * FROM magazina WHERE magazino_id=$id";
// $id do ta kalosh nepermjet url ose me ndonje form dmth me ane te POST ose GET psh insert.php?id=1
if (!$result = mysql_query($sql)) {
echo "Errore " . mysql_error();
}
$row = mysql_fetch_assoc($result);
$magazinonome = $row['magazinonome'];
echo <<<END
<html>
<head>
</head>
<body>
Mbush formulierin dhe shtyp 'invia queri'
Formular ab:
<form action = "$PHP_SELF" method = "post">
<input name="mn" value="$magazinonome"> Magazinonome<p>
<input name="pn"> Prodottonome<p>
<input name="qn"> Quantita<p>
<input type="hidden" name="magazino_id" value="$id">
<input type="submit" name="gesendet">
<input type="reset">
</form>
Alle Datensätze <a href="selekt.php">anzeigen</a>
</body>
</html>
END;
}
else {
$sql = "INSERT INTO prodotti (magazino_id, prodottonome, quantita) VALUES('$magazino_id', '$pn', '$qn');";
if (!$result = mysql_query($sql)) {
echo "Errore " . mysql_error();
}
else {
echo "<h2 align='center'>Artikulli u shtua me sukses</h2>";
}
}
mysql_close();
?>
Shenim:
Fusha(field) prodotti_id tek tabela prodotti duhet te jete AUTO INC