/
coments.php
172 lines (145 loc) · 5.09 KB
/
coments.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<div id="comentarios">
<?php
require "conexion/conexion.php";
require 'include/fecha.php';
require 'include/funciones.php';
$publicado="Publicado";
?>
<script>
jQuery(function($){
// simple jQuery validation script
$('#form1').submit(function(){
var valid = true;
var errormsg = 'Campo requerido..!';
var errorcn = 'error';
$('.' + errorcn, this).remove();
$('.required', this).each(function(){
var parent = $(this).parent();
if( $(this).val() == '' ){
var msg = $(this).attr('title');
msg = (msg != '') ? msg : errormsg;
$('<span class="'+ errorcn +'">'+ msg +'</span>')
.appendTo(parent)
.fadeIn('fast')
.click(function(){ $(this).remove(); })
valid = false;
};
});
return valid;
});
})
</script>
<?php
$actualiza="<META HTTP-EQUIV='Refresh' CONTENT='1; URL=index.php'>";//actualizamos la pagina
$sql="select name, comentarios,fecha from comentarios where publicado='$publicado' and estado='OK' order by fecha "; //c�digo MySQL
$datos=mysql_query($sql,$html_link); //enviar c�digo MySQL
while ($row=mysql_fetch_array($datos)) { //Bucle para ver todos los registros
$name=$row['name']; //datos del campo nombre
$comentarios=$row['comentarios']; //datos del campo tel�fono
$fecha=$row['fecha']; //datos del campo email
//echo "$name, $comentarios, $fecha. <br/>"; //visualizar datos
?>
<!-- presentar mensajes-->
<div id="section">
<ol class="messageList">
<li class="message">
<div class="messageUserInfo">
<div class="messageUserBlock">
<div class="avatarHolder">
<a href="#" class="avatar"><img src="avatar/images.jpg" width="96" height="96" alt="" /></a>
</div> <!-- avatarHolder-->
<h3 class="userText">
<!--<a href="#" class="username">victor</a>-->
<em class="userBanner bannerStaff wrapped">
<span class="before"></span>
<strong><?php echo $name; ?></strong>
<span class="after"></span>
</em>
</h3> <!-- usertext-->
<span class="arrow"><span></span></span></div>
<!-- messageUserBlock-->
</div> <!-- messageUserinfo-->
<div class="messageInfo primaryContent">
<div class="messageContent">
<article><blockquote class="messageText"><span class="quote"></span><?php echo $comentarios; ?></blockquote></article>
</div> <!-- messageContent-->
</div> <!-- messageInfo primary content-->
<div class="messageMeta">
<div class="privateControls"><span class="item muted">Publicado : <?php echo date("d-m-Y",strtotime($fecha)) ; ?></span></div>
</div> <!--massagemeta-->
</li> <!-- message-->
</ol>
</div><!--section-->
<?php
}
?>
<div class="comments-padding">
<div id="respond">
<h3><span>Dejanos tu comentario</span></h3>
<div>
<?php
if(isset($_POST['publicar']))//Vallidamos que el formulario fue enviado
{
/*Validamos que todos los campos esten llenos correctamente*/
if(($_POST['nombre'] != '') && ($_POST['email'] != '') && ($_POST['comentarios'] != ''))
{
if(!validarnombre($_POST['nombre']))
{
echo '<p>nombre solo 20 caracteres</p>';
}
else
{
if(!validar_email($_POST['email']))
{
echo '<p>email inválido</p>';
}
else {
$nombre= limpiar($_POST['nombre']);
$email= limpiar($_POST['email']);
$comentarios= limpiar($_POST['comentarios']);
$ipuser= $_SERVER['REMOTE_ADDR'];
if(validarcomentarios($_POST['comentarios']))
{
$estado='OK'; // Cambiar por SR si deseas que todos los mensajes no se publiquen hasta que los hayas revisado.
$fecha=date("Y-m-d");
$publicado="Publicado";
$query=mysql_query("insert into comentarios (publicado , fecha , name, email , comentarios , estado) values ('$publicado', '$fecha', '$nombre', '$email' , '$comentarios','$estado' )");
echo mysql_error();
echo "Gracias por su comentario. espere..... <br>".$actualiza;//ACTULIZAMOS DESPUES DE GUARDAR
}
else
{
echo '<p>Comentario min. 260 caract.</p>';
}
}//else email
}//else nombre
} //cerramos que esten llenos todos los campos
else
{
echo '<h5>Deberas llenar todos los campos.</h5>';
}
} //isset post publicar
?>
</div>
<form action="" method="post" id="form1" name="form1">
<div>
<input name="nombre" type="text" required class="comments-input-text required" tbindex="1" Title="Ingres su nombre →" >
<label for="nombre"><small>Nombre (max 20 caract.)</small></label>
</div>
<div>
<input name="email" required type="email" class="comments-input-text required" tabindex="1" title="ingrese su email →" >
<label for="email"><small>email (ingrese correo valido)</small></label>
</div>
<label for="comentarios"><small>(min 260 caract.)</small></label>
<div>
<textarea name="comentarios" required cols="40" rows="3" class="comments-input-textarea required" tabindex="4" title="Ingrese su comentario →" ></textarea>
</div>
<br />
<div class ='button-submit-comment-margin'>
<input type="submit" name="publicar" class="button-submit-comment" id="publicar" value="Publicar">
</div>
<div class="clear"></div>
</form>
</div><!--respond-->
</div><!--comment-padding-->
</div>