Hola, soy nuevo en esto y estoy iniciando con PHP.
 
Llevo días intentando hacer algo que parece muy sencillo. Necesito mostrar un mensaje de si el usuario ya está o no registrado.
 
Para ello trato de hacer una consulta en BBDD donde en la columna "validar" tiene valores del tipo tinyint(1).
 
Agradezco vuestra inestimable ayuda. A continuación pego el código:
 
<?php  
$dni = $_POST['dni']; 
 
include('abre_conexion.php');   
 
    $query = "select * from $tabla_db1 where dni = '$dni'"; 
    $result = mysql_query($query); 
 
while ($registro = mysql_fetch_array($result)){ 
 
echo " 
<body> 
 
<div align='center'> 
    <table border='0' width='600' style='font-family: Verdana; font-size: 8pt' id='table1'> 
        <tr> 
            <td colspan='2'><h3 align='center'>Registro de promociones</h3></td> 
        </tr> 
        <tr> 
            <td colspan='2'>Compruebe si el usuario ha usado la promoción. En caso negativo, proceda a registrarlo mediante la casilla de validación</td> 
        </tr> 
        <form method='POST' action='actualiza.php'> 
        <tr> 
            <td width='50%'> </td> 
            <td width='50%'> </td> 
        </tr> 
        <tr> 
            <td width='50%'><p align='right'><b>Nombre: </b></td> 
            <td width='50%'><p align='left'>".$registro['nombre']."</td> 
        </tr> 
        <tr> 
            <td width='50%'><p align='right'><b>Apellido:</b></td> 
            <td width='50%'><p align='left'>".$registro['apellido']."</td> 
        </tr> 
        <tr> 
            <td width='50%'><p align='right'><b>DNI:</b></td> 
            <td width='50%'><p align='left'>".$registro['dni']."</td> 
        </tr>
		<tr> 
            <td width='50%'> </td> 
            <td width='50%'> </td> 
        </tr> 
        <tr> 
            <td width='100%' colspan='2'>
				<p align='center'>Este usuario <?php if($validar==0){echo'NO'}else{echo'SI'}?> está registrado</p>
			</td> 
        </tr> 
		<tr> 
            <td width='50%'> </td> 
            <td width='50%'> </td> 
        </tr> 
		<tr> 
            <td width='50%'><p align='right'><b>Validar:</b></td>
            <td width='50%'><p align='left'><input type='checkbox' name='validar' value='1'></td> 
        </tr> 
 
		<tr> 
            <td width='50%'> </td> 
            <td width='50%'> </td> 
        </tr> 
        <input type='hidden' name='dni' value='$dni'> 
        <tr> 
            <td width='100%' colspan='2'> 
            <p align='center'> 
            <input type='submit' value='Registrar promoción' name='B1'></td> 
        </tr> 
        </form> 
    </table> 
</div> 
"; 
} 
include('cierra_conexion.php');   
?> 
  
 

