Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Google translate:
I'm making a web page, and I want to schedule a comment section to it, that contains the date and time the user commented. Being a first-timer in the subject, I'm doing badly using the JavaScript language for that case; Also AJAX. I wish that once the data is sent to MYSQL, it will be returned to the page.


Google translate:
This is my HTML code:

HTML
<form name="f_coment" action= "insertar.php" method="POST">
    <Label for="nombre">Nombre:</Label>
    <input type="text" name="nombre" required=""placeholder="Escribe tu nombre..."><br>
    <label for="email">Email:</label>
    <input type="email" name="email"  required=""placeholder="Escribe tu email..."> <br>
    <label for="clave">Clave:</label>
    <input type="password" name="clave" required="" placeholder="Escribe tu clave..."><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" id="comentar">
</form>



Google translate:
This is my PHP code:

PHP
<?php 
    error_reporting(0);
    
    $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();
    }
?>



Google translate:
I would really appreciate any help.


What I have tried:

Quote:
This is a piece of Java code that I could try:

JavaScript
function getFormValues{
    var nombre = document.f_coment.nombre.value;
    var email = document.f_coment.email.value;
    var clave = document.f_coment.clave.value;
    var comentario = document.f_coment.comentario.value;
}
Posted
Updated 24-Jan-19 9:04am
v8
Comments
Richard Deeming 24-Jan-19 14:55pm    
Please post in English.

En inglés, por favor.

:)
Member 14128840 24-Jan-19 15:23pm    
Yes, it is already...
Richard Deeming 25-Jan-19 6:44am    
Only because I added the English translation for you. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900