Código PHP:
<?
$host = "localhost";
$user = "mysql";
$pass = "mysql";
$dbname = "sistemacomentarios";
$conecta = mysql_connect($host,$user,$pass);
mysql_select_db($dbname,$conecta);
if(isset($HTTP_POST_VARS["id"]) && isset($HTTP_POST_VARS["nick"]) && isset($HTTP_POST_VARS["comentario"]))
{
if($HTTP_POST_VARS["comentario"] != "")
{
if($HTTP_POST_VARS["nick"] == "")
{
$nickNuevo = "anonimo";
}
else
{
$nickNuevo = $HTTP_POST_VARS["nick"];
}
$resultCom2 = mysql_query("SELECT id FROM comentarios ORDER BY id DESC LIMIT 0,1");
$rowCom2 = mysql_fetch_array($resultCom2);
$con = $rowCom2["id"];
mysql_free_result($resultCom2);
$con++;
$idNoticia = $HTTP_POST_VARS["id"];
$comentarioNoticia = $HTTP_POST_VARS["comentario"];
mysql_query("INSERT INTO comentarios VALUES
('$con','$idNoticia','$nickNuevo','$comentarioNoticia',NOW())");
echo "Comentario Enviado Con Exito";
}
else
{
echo "Debe Introducir Un Comentario.";
}
}
mysql_close();
?>