QUESTA E' LA PAGINA CHE MOSTRA I COMMENTI E MI PERMETTE DI INSERIRLI
Codice PHP:
<?
include("config.inc.php");
$db = mysql_connect($db_host, $db_user, $db_password);
if ($db == FALSE)
die ("Errore nella connessione. Verificare i parametri nel file config.inc.php");
mysql_select_db($db_name, $db)
or die ("Errore nella selezione del database. Verificare i parametri nel file config.inc.php");
$dati=mysql_query("select * from commenti where id_art='$id_art' order by data desc");
while($array=mysql_fetch_array($dati)){
echo"$array[data] da ";
echo"<a href=mailto:$array[utente]>$array[utente]</a>
";
echo"$array[commento]
";
}
?>
<input type="button" value="link" onclick="document.theform.commento.innerHTML+='[a][/a]'">
<input type="button" value="codice" onclick="document.theform.commento.innerHTML+='[code][/code]'">
<input type="button" value="grassetto" onclick="document.theform.commento.innerHTML+='[b][/b]'">
<form method="post" action="commenti_salva.php" name="theform">
<input type="hidden" value="<?echo $id;?>" name="idart" >
<input type="hidden" value="<?echo $titolo;?>" name="titart">
Email :<input type="text" value="" name="email">
Commento:
<textarea rows=13 cols=60 name="commento"></textarea>
<input type="submit" value="Inserisci">
</form>
QUESTA E' LA PAGINA CHE SALVA I COMMENTI
Codice PHP:
<?
include("config.inc.php");
$db = mysql_connect($db_host, $db_user, $db_password);
if ($db == FALSE)
die ("Errore nella connessione. Verificare i parametri nel file config.inc.php");
mysql_select_db($db_name, $db)
or die ("Errore nella selezione del database. Verificare i parametri nel file config.inc.php");
$data= date("d/m/y",time());
$new=$commento;
$new=str_replace("<?","<?",$new);
$new=str_replace("<?php","<?php",$new);
$new=str_replace("<","<",$new);
$new=str_replace("[a]","<a href=",$new);
$new=str_replace("[/a]",">link</a>",$new);
$new=str_replace("[code]","<p class=codice>",$new);
$new=str_replace("[/code]","</p>",$new);
$new=str_replace("[b]","[b]",$new);
$new=str_replace("[/b]","[/b]",$new);
$new = ereg_replace("\n","
",$new);
$dati=mysql_query("insert into commenti(data,id_art,tit_art,commento,utente) values ('$data','$idart','$titart','$new','$email')");
?>
Non riesco ad assegnare all'id_art (nella tabella dei commenti) l'id deil'articolo.
Come posso fare?
Grazie mille in anticipo e buona domenica a tutti.