How do I make my computer display the data on the same page of a form simultaneously when they are sent to a database? It is for a comments section that I have planned to put on the web page that I am creating and also put the date and time respective to each comment
This is the form:
<form action="insertar.php" method="POST">
<Label for="nombre">Nombre:</Label>
<input type="text" name="nombre" required=""placeholder="Escribe tu nombre..."><br><br>
<label for="email">Email:</label>
<input type="email" name="email" required=""placeholder="Escribe tu email..."> <br><br>
<label for="clave">Clave:</label>
<input type="password" name="clave" required="" placeholder="Escribe tu clave..."><br><br>
<label for="comentario">Comentario:</label>
<textarea type="comentario" name="comentario" cols="90px" rows="8" required="" placeholder="Escriba aquí su comentario..."></textarea><br><br>
<input type="submit" value="Comentar">
</form>
This is the PHP connection:
<?php
$PDO = new PDO('mysql:host=localhost;dbname=db_comentarios;charset=UTF8','root','' );
try {
echo "datos enviados correctamente";
$sql=$PDO->prepare("INSERT INTO prueba1(nombre, email, clave, comentario) VALUES (:nombre, :email, :clave, :comentario)");
$sql->bindParam(':nombre',$_POST['nombre']);
$sql->bindParam(':email',$_POST['email']);
$sql->bindParam(':clave', password_hash($_POST['clave'], PASSWORD_DEFAULT));
$sql->bindParam(':comentario',$_POST['comentario']);
$sql->execute();
}catch(PDOException $e) {
echo "Fallo de conexion al enviar los datos:".$e->getMessage();
}
?>