I'm making a website, but I do not remember how to do this procedure ... an example is:
Name: (empty field) Last name: (empty field) and passing data from mysql would look like this: Name: Juan Surnames: Perez Godinez.
I'm making a website, but I do not remember how to do this procedure ... an example is:
Name: (empty field) Last name: (empty field) and passing data from mysql would look like this: Name: Juan Surnames: Perez Godinez.
Your question is not very descriptive or detailed. But I will try to be as explicit as possible. Since you only need "the procedure". It depends on how you want to show the result later.
// ---- PHP -----
// Crear la conexión con la base de datos.
$link = mysql_connect(' <mysql Host> ', ' <mysql Usuario> ', ' <mysql contraseña> ')
or die('No se pudo conectar: ' . mysql_error());
mysql_select_db(' <Nombre de la base de datos> ') or die('No se pudo seleccionar la base de datos');
// Realizar la consulta de los datos necesarios en la página.
$query = 'SELECT nombre, apellido FROM usuarios LIMIT 1';
$result = mysql_query($query) or die('Consulta fallida: ' . mysql_error());
$nombre = "";
$apellido = "";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$nombre = $line['nombre'];
$apellido = $line['apellido'];
}
//Mostrar los datos de la consulta.
echo "<label> Nombre:</label>";
// Input
echo "<input type='text' value='".$nombre."'/>";
// Texto
echo "<label>'".$nombre."'</label>";
echo "<label> Apellido:</label>";
// Input
echo "<input type='text' value='".$apellido."'/>";
// Texto
echo "<label>'".$apellido."'</label>";
Interaction between the 2 files. In the system.php file you will only need to show the variable or if you do not have it in a variable, you have the code at the top to have the data in variable separately before showing them.
//-- system.php
include ("verificar.php"); // Estando en el mismo directorio
echo "<label> Nombre:</label>";
// Input
echo "<input type='text' value='".isset($nombre) ? $nombre : ""."'/>";
// En caso de que no exista la variable "nombre" si proviene de "verificar.php" que muestre vacío
The first thing is that in order to do what you indicate, you must have already consulted the data to be printed.
On the other hand, assuming that you are using PHP in its simplest form to fill a field of a form you need is the echo function, this instruction allows you to print the value on the web page by ex:
echo("Javier");
Or if you have defined a variable (which should be your case):
echo($nombre);
In a web form it would be something more like:
<input type="text" name="nombre" value="<?php echo($nombre) ?>" />
The previous thing would make that the field of the form already appears with data previously filled in.