Sistema de comentarios
Hola, estoy creando un sistema de comentarios, pero no me permite hacer salto de párrafo ni de línea automáticamente.
También necesito saber cómo puedo crear íconos que inserten letra bold, itálica y subrayada para que los usuarios puedan resaltar partes de su comentario con dar click a un botón, considerando que por lo general no tienen idea de códigos o etiquetas.
El archivo php que estoy utilizando es este:
<?php if (isset($_GET['addcomen'])): // If the user wants to add a comment
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>Type your comment here:<br />
<textarea name="comenext" rows="10" cols="40">
</textarea></label><br />
<input type="submit" value="SUBMIT" />
</form>
<?php else: // Default page display
// Connect to the database server
$dbcnx = @mysql_connect('mysq.worria.com', 'user', 'pass');
if (!$dbcnx) {
exit('
<p>Unable to connect to the ' .
'database server at this time.</p>
');
}
// Select the comments database
if (!@mysql_select_db('manuel_mariana')) {
exit('
<p>Unable to locate the comment ' .
'database at this time.</p>
');
}
// If a comment has been submitted,
// add it to the database.
if (isset($_POST['comenext'])) {
$comenext = $_POST['comenext'];
$sql = "INSERT INTO comen1 SET
comenext='$comenext',
comendate=CURDATE()";
if (@mysql_query($sql)) {
echo '
<p>Your comment has been added.</p>
';
} else {
echo '
<p>Error adding submitted comment: ' .
mysql_error() . '</p>
';
}
}
echo '
<p>Here are all the comments in our database:</p>
';
// Request the text of all the comments
$result = @mysql_query('SELECT comenext FROM comen1');
if (!$result) {
exit('
<p>Error performing query: ' .
mysql_error() . '</p>
');
}
// Display the text of each comment in a paragraph
while ($row = mysql_fetch_array($result)) {
echo '
<p>' . $row['comenext'] . '</p>
';
}
// When clicked, this link will load this page
// with the comment submission form displayed.
echo '
<p><a href="' . $_SERVER['PHP_SELF'] .
'?addcomen=1">Add a comment!</a></p>
';
endif;
?>
También necesito saber cómo puedo crear íconos que inserten letra bold, itálica y subrayada para que los usuarios puedan resaltar partes de su comentario con dar click a un botón, considerando que por lo general no tienen idea de códigos o etiquetas.
El archivo php que estoy utilizando es este:
<?php if (isset($_GET['addcomen'])): // If the user wants to add a comment
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>Type your comment here:<br />
<textarea name="comenext" rows="10" cols="40">
</textarea></label><br />
<input type="submit" value="SUBMIT" />
</form>
<?php else: // Default page display
// Connect to the database server
$dbcnx = @mysql_connect('mysq.worria.com', 'user', 'pass');
if (!$dbcnx) {
exit('
<p>Unable to connect to the ' .
'database server at this time.</p>
');
}
// Select the comments database
if (!@mysql_select_db('manuel_mariana')) {
exit('
<p>Unable to locate the comment ' .
'database at this time.</p>
');
}
// If a comment has been submitted,
// add it to the database.
if (isset($_POST['comenext'])) {
$comenext = $_POST['comenext'];
$sql = "INSERT INTO comen1 SET
comenext='$comenext',
comendate=CURDATE()";
if (@mysql_query($sql)) {
echo '
<p>Your comment has been added.</p>
';
} else {
echo '
<p>Error adding submitted comment: ' .
mysql_error() . '</p>
';
}
}
echo '
<p>Here are all the comments in our database:</p>
';
// Request the text of all the comments
$result = @mysql_query('SELECT comenext FROM comen1');
if (!$result) {
exit('
<p>Error performing query: ' .
mysql_error() . '</p>
');
}
// Display the text of each comment in a paragraph
while ($row = mysql_fetch_array($result)) {
echo '
<p>' . $row['comenext'] . '</p>
';
}
// When clicked, this link will load this page
// with the comment submission form displayed.
echo '
<p><a href="' . $_SERVER['PHP_SELF'] .
'?addcomen=1">Add a comment!</a></p>
';
endif;
?>
Respuesta de davidcortesb
1