Ho fatto per te uno script di esempio...
http://82.85.241.162/
Testa tu stesso (P.S. questo server è mio e potrebbe nn essere sempre disponibile soprattutto in settimana)
SOMMARIO.PHP
Codice PHP:
<?php
$c = mysql_connect ('localhost', 'root', 'LeLoF!GhT82') or die (mysql_error());
mysql_select_db('lol', $c) or die (mysql_error());
if(isset($_GET['id'])) {
$id = $_GET['id'];
$q = mysql_query("SELECT * FROM storielle WHERE id=$id");
$d = mysql_fetch_array($q);
$titolo = $d['titolo'];
$racconto = $d['racconto'];
print "<center><h2>$titolo</h2>
\n$racconto
\n
\n[url='sommario.php']Torna al sommario[/url]";
} else {
$q = mysql_query("SELECT * FROM storielle;");
while ($d = mysql_fetch_array($q)) {
$id = $d['id'];
$titolo = $d['titolo'];
$racconto = $d['racconto'];
print "[url='sommario.php?id=$id']$titolo[/url]
\n";
}
}
?>
insert_storiella.php
Codice PHP:
<form action='insert_storiella.php?go' method='POST'>
titolo: <input typE='text' name='titolo'>
racconto:
<textarea width='300' height='200' name='racconto'></textarea>
<input type='submit' value='Inserisci'>
</form>
<?php
if(isset($_GET['go'])) {
if(isset($_POST['titolo']) && isset($_POST['racconto'])) {
$titolo = $_POST['titolo'];
$racconto = $_POST['racconto'];
$c = mysql_connect('localhost','root','LeLoF!GhT82') or die(mysql_error());
mysql_select_db('lol', $c);
$query = mysql_query("INSERT INTO storielle (titolo, racconto) VALUES ('$titolo', '$racconto');");
if($query) {
print "COmmento inserito correttamente";
} else {
print "Errore durante l'inserimento del commento";
}
}
}