INTRODUCCION Bueno Hola, aqui les traigo un pequeño code para crear un sistema de comentarios La mayoria que encontraras en internet usan BASES DE DATOS O SQL. Este codigo es sencillo este codigo es convenite para los que estan enpezando en php, poque es un codigo pequeño
CODIGOCreamos primero el archivo comentarios.php este code esta basado en un ajax
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Comenta Mi Web</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$(".submit").click(function() {
var comment = $("#comment").val();
var dataString = 'comment=' + comment;
if(comment=='')
{
alert('No has enviada!');
}
else
{
$("#flash").show();
$("#flash").fadeIn(400).html('Loading Comment...');
$.ajax({
type: "POST",
url: "comentarios2.php",
data: dataString,
cache: false,
success: function(html){
$("ol#update").append(html);
$("ol#update li:last").fadeIn("slow");
document.getElementById('comment').value='';
$("#name").focus();
$("#flash").hide();
}
});
}
return false;
});
});
</script>
</head>
<body>
<div id="main">
<div style="margin-left:100px">
<form action="#" method="post">
<textarea name="comment" id="comment"></textarea><br />
<input type="submit" class="submit" value="Enviar" />
</form>
</div>
<ol id="update" class="timeline"></ol>
<div id="flash" align="left" ></div>
</div>
</body>
</html> |
comentarios2.php este ya es php
if( $_POST) { $comment=$_POST['comment']; }
echo " ."$comment.""; ?> CREDITOS: MARTIN COMPUNET |
|