Hola, yo hice un formulario mas o menos así, te dejo el código para que le eches un vistazo, haber si te sirve de algo...
Consulta:
Código PHP:
<?php
$conexion=mysql_connect("localhost","root","");
mysql_select_db("poker",$conexion)
or die ("*****Conexion a base de datos no realizada*****");
$resul=mysql_query("SELECT * FROM socios ORDER BY nsocio",$conexion);
(Hago la tabla en html)
[HTML]
<table width="562" height="64" border="1">
<tr>
<th width="100" scope="col"><span class="Estilo7">Nº Socio</span></th>
<th width="140" scope="col"><span class="Estilo7">Nombre</span></th>
<th width="172" scope="col"><span class="Estilo7">Apellidos</span></th>
<th width="111" scope="col"><span class="Estilo7">DNI</span></th>
</tr>
</table>
[/HTML]
while ($fila=mysql_fetch_array($resul))
{
echo "<tr>" ;
echo "<td><a href='socios.php?nsocio=$fila[nsocio]'>$fila[nsocio]</a></td>";
echo "<td>$fila[nombre]</td>";
echo "<td>$fila[apellidos]</td>";
echo "<td>$fila[dni]</td>";
echo "</tr>";
}
Al pinchar en el nsocio me lleva a socios.php donde visualizo los datos de este socio
Código PHP:
<form id="form4" method="post" action="">
<p>
<label><span class="Estilo7">Nº Socio:</span>
<input name="nsocio" type="text" size="7" value="<?php echo $fila[nsocio];?>" method="get"/>
</label>
</p>
<p align="left"><img name="foto" src="<?php echo 'fotosocios/'.$fila[foto];?>" width="119" height="140" alt="" /></p>
<p>
<label><span class="Estilo7"> Nombre:</span>
<input type="text" name="nombre" value="<?php echo $fila[nombre];?>"/>
</label>
</p>
<p>
<label><span class="Estilo7">Apellidos:</span>
<input name="apellidos" type="text" size="30" value="<?php echo $fila[apellidos];?>"; />
</label>
</p>
<p>
<label><span class="Estilo7">DNI:</span>
<input name="dni" type="text" size="20" value="<?php echo $fila[dni];?>" method="get" />
</label>
</p>
<p>
<label><span class="Estilo7">Dirección:</span>
<input name="direccion" type="text" size="40" value="<?php echo $fila[direccion];?>"/>
</label>
</p>
<p>
<label><span class="Estilo7">Población:</span>
<input name="poblacion" type="text" size="30" value="<?php echo $fila[poblacion];?>"/>
</label>
</p>
<p>
<label><span class="Estilo7">Código Postal:</span>
<input name="codigopos" type="text" size="12" value="<?php echo $fila[codigopos];?>"/>
</label>
</p>
<p>
<label><span class="Estilo7">Teléfono:</span>
<input name="telefono" type="text" value="<?php echo $fila[telefono];?>" />
</label>
</p>
<p>
<label><span class="Estilo7">Otros datos de interés:</span><br />
<textarea name="otro" cols="50" rows="7"> <?php echo $fila[otro];?> </textarea>
</label>
</p>
<p>
<label><span class="Estilo7">Foto:</span>
<input type="file" name="foto" />
</label>
</p>
<p>
<?php $pagado = $fila["pagado"];
$checked = ($pagado != 2)?" checked ":""; ?>
</p>
<p>
<label class="Estilo7">Pagado:</label>
<label>
<input type="checkbox" name="pagado" <?php echo $checked; ?>>
</label>
</p>
<p>
<label>
<div align="center">
</label>
</form>
<div align="center"></div>
<label>
<div align="center">
<div align="center">
<input type="submit" name="boton" value="Borrar" onClick="this.form.action='borrar.php'"/>
<input type="submit" name="boton" value="Actualizar" onClick="this.form.action='actualizar.php'"/>
como ves tengo dos botones un que llama a borrar.php, para borrar al socio y otro actualizar, para modificar los datos.
Borrar.php
Código PHP:
<?php
$conexion=mysql_connect("localhost","root","");
mysql_select_db("poker",$conexion) or die ("***** Conexión a base de datos no realizada*****");
$dni=$_REQUEST['dni'];
$resul=mysql_query("DELETE FROM socios WHERE dni='$dni'",$conexion);
if (mysql_errno ($conexion)==0)
echo "<center><b class='Estilo1 Estilo2'>Socio borrado</b></center>";
else
echo "<center><b>Error en al borrar</b></center>";
$conexion=mysql_close($conexion);
?>
actualizar.php
Código PHP:
<?php
$conexion=mysql_connect("localhost","root","");
mysql_select_db("poker",$conexion) or die ("***** Conexión a base de datos no realizada*****");
$pagado= (isset($_REQUEST["pagado"])?$_REQUEST["pagado"]:2);
$resul=mysql_query("UPDATE socios SET nsocio='$nsocio',nombre='$nombre', apellidos='$apellidos', dni='$dni', direccion='$direccion', poblacion='$poblacion', codigopos='$codigopos', telefono='$telefono', otro='$otro', foto='$foto', pagado='$pagado'",$conexion);
if (mysql_errno ($conexion)!=0)
echo "<center><b class='Estilo1 Estilo2'>No actualizado</b></center>";
else
echo "<center><b class='Estilo1 Estilo2'>Actualizado</b></center>";
$conexion=mysql_close($conexion);
?>