Attualmente uso due Files per il Modulo Commenti, ma per questione di comodità e semplicità vorrei semplificarlo ad uno. E' parecchio che tento in ques'impresa ma mai riuscito, il problema è che cliccando sul Submit del Form mi reidirizza sulla pagina stesso, propio come deve essere, MA non c'è alcun commento nel DataBase. Ecco lo script:
Codice PHP:
/* -- Connessione al Database dei Commenti -- */
include 'database_commenti.php';
if(count($_POST) > 0)
{
$ip = $_SERVER['REMOTE_ADDR'];
$agent = $_SERVER['HTTP_USER_AGENT'];
$date_db = time();
$nickname = htmlentities($_POST['nickname']);
$commento = htmlentities($_POST['commento']);
if(!empty($nickname) || !empty($commento))
{
/* -- Controllo se i Campi contengano Testo -- */
if (empty($nickname))
{
$status = "[b]Inserisci il tuo Nickname![/b]";
(isset($commento)) ? $commento_text = $commento : $commento_text = "";
}
if (empty($commento)) $status = "[b]Inserisci il tuo Commento![/b] (max 250 caratteri)";
}
else
{
$db_commenti_sec = "INSERT INTO " . $sec . " (filename_code_extension, nickname, commento, userIP, country, date, agent) ";
$db_commenti_sec.= "VALUES ('$sourceID', '$nickname', '$commento', '$ip', '$country', '$date_db', '$agent')";
/* -- Salvataggio del NickName e del Commento nel DataBase -- */
$write = mysql_query ($db_commenti_sec) or die (mysql_error());
if ($write === FALSE) $status = "Errore nel salvataggio del commento. Riprova.";
else $status = "Il commento è stato inserito correttamente";
}
}