Hello, I am preparing a form to load data from a MYSQl database, it is the same data that I enter, I just want that in this form they can be edited, the code I have is:
<?php
// 1) Conexión
if ($conexión = mysql_connect("localhost", "root", "clave")){
echo "<p>MySQL le ha dado permiso a PHP para ejecutar consultas con ese usuario</p>";
// 2) Preparar la orden SQL
$consulta= "SELECT*FROM mensajes";
// 3) Ejecutar la orden y obtener datos
mysql_select_db("cursos");
$datos= mysql_query ($consulta);
// 4) Ir Imprimiendo las filas resultantes
while ($fila =mysql_fetch_array($datos)){
echo "<p">;
echo $fila ["id"];
echo "-"; // un separador
echo $fila["nombre"];
echo "-"; // un separador
echo $fila ["email"];
echo "-"; // un separador
echo $fila["mensaje"];
echo "</p>";
}
}else{
echo "MySQL no conoce ese usuario y password";
}
?>
this works but not only I want to show them (echo), what I want is to inject the data to the HTML form (name, email, etc), with the purpose of editing the information previously entered, (without using javascript)
<!-- formulario de contacto para el ingreso de datos -->
<form action="envia.php" method="post" class="form-consulta">
<label>Nombre y apellido: <span>*</span>
<input type="text" name="nombre" placeholder="Nombre y apellido" class="campo-form" required>
</label>
<label>Email: <span>*</span>
<input type="email" name="email" placeholder="Email" class="campo-form" required>
</label>
<label>Consulta:
<textarea name="consulta" class="campo-form"></textarea>
</label>
<input type="submit" value="Enviar" class="btn-form">
</form>
<!-- formulario -->
I found an unconventional way with javascript and it works for me but I want to do it, more suitable, to avoid that the script blockers cancel the function,: D I accept your comments, help and suggestions, greetings to all