disculpa la tardanza amigo este es el formulario se llama alumregdatos.php
Código HTML:
[PHP]
<form name="form1" method="post" action="agregarni.php">
Nombres <input name="ninombre" type="text" size="25" maxlength="25">
Apellidos:<input name="niapellido" type="text" size="25" maxlength="25">
Cedula:<input name="cedulani" type="text" size="10" maxlength="10">
Fecha de Nacimiento:<input name="nifechan" type="text" value="dd-mm-yyyy" size="15" maxlength="10">
Direccion:<textarea name="nidireccion" cols="35"></textarea>
<? $ano=date("Y");
$mes=date("F");
$dia=date("d");
if ($mes=="January") $mes="01";
if ($mes=="February") $mes="02";
if ($mes=="March") $mes="03";
if ($mes=="April") $mes="04";
if ($mes=="May") $mes="05";
if ($mes=="June") $mes="06";
if ($mes=="July") $mes="07";
if ($mes=="August") $mes="08";
if ($mes=="September") $mes="09";
if ($mes=="October") $mes="10";
if ($mes=="November") $mes="11";
if ($mes=="December") $mes="12";
?>
Año de Ingreso <input name="niaño" type="text" value="<? echo $ano?>" size="4" maxlength="4" onfocus="this.blur()">
<select name="facni">
<option value="Ingenieria">Ingenieria</option>
</select>
Carrera:
<select name="carrera">
<option value="Civil">Civil</option>
<option value="Industrial">Industrial</option>
<option value="Sistemas">Sistemas</option>
<option Value="Telecomunicaciones">Telecomunicaciones</option>
</select>
Numero Del Boucher:<input name="nboucher" type="text" size="15">
Fecha Inscripción:<input name="fecha" type="text" value="<? echo $dia?>-<? echo $mes?>-<? echo $ano?>" size="10" maxlength="10" onfocus="this.blur()">
<input type="submit" value = "Registrar Datos" >
<input type="reset" value = "Cancelar" >
</form>
[/PHP]
y esta es la pagina donde hago la consulta y compruebo la valides del formulario. se llama agregarni.php
Código PHP:
<?
trim($nboucher);
trim($ninombre);
trim($niapellido);
trim($cedulani);
trim($nifechan);
trim($nidireccion);
$db = mysql_connect("localhost", "root");
mysql_select_db("usm",$db);
$existe = @ mysql_num_rows(mysql_query("SELECT planilla FROM banco WHERE planilla = ".$nboucher));
if (!$nboucher || !$ninombre || !$niapellido || !$cedulani || !$nifechan ||!$nidireccion)
{echo ?>
<table width="400" border="0" align="center">
<tr>
<td height="49" align="center"><img src="prueba/advertencia.gif"></td>
</tr>
</table>
<table width="400" border="0" bordercolor="#000000" align="center">
<tr> <td><img src="prueba/icone_advertencia2.gif"></td>
<td bgcolor="#32afde" align="center"><p><font color="#000000" size="+1" face="Courier New, Courier, mono"><strong>Debe llenar Todos los Campos.</strong></font></p>
<p><font color="#000000" size="+1" face="Courier New, Courier, mono"><strong><a href="alumnregdatos.php"><img src="prueba/botonATRAS.gif" width="75" height="62" border="0"></a></strong></font></p></td>
</tr>
</table>
<?
exit;}
if ( $existe ==0) {
echo ?>
<p> </p>
<table width="400" border="0" align="center">
<br>
<br>
<br>
<br>
<tr>
<td height="49" align="center"><img src="prueba/advertencia.gif"></td>
</tr>
</table>
<table width="400" border="0" bordercolor="#000000" align="center">
<tr> <td><img src="prueba/icone_advertencia2.gif"></td>
<td bgcolor="#32afde" align="center"><p><font color="#000000" size="+1" face="Courier New, Courier, mono"><strong>El Número del Boucher no es valido por favor intente de nuevo.</strong></font></p>
<p><font color="#000000" size="+1" face="Courier New, Courier, mono"><strong><a href="alumnregdatos.php"><img src="prueba/botonATRAS.gif" width="75" height="62" border="0"></a></strong></font></p></td>
</tr>
</table>
<?
exit;}
$comprobarboucher = mysql_num_rows(mysql_query("SELECT num_boucher FROM boucher WHERE num_boucher = ".$nboucher));
if ( $comprobarboucher >=1)
{ echo?>
<p> </p>
<table width="400" border="0" align="center">
<br>
<br>
<br>
<br>
<tr>
<td height="49" align="center"><img src="prueba/advertencia.gif"></td>
</tr>
</table>
<table width="400" border="0" bordercolor="#000000" align="center">
<tr> <td><img src="prueba/icone_advertencia2.gif"></td>
<td bgcolor="#32afde" align="center"><p><font color="#000000" size="+1" face="Courier New, Courier, mono"><strong>El Número del Boucher ya ha sido procesado...</strong></font></p>
<p><font color="#000000" size="+1" face="Courier New, Courier, mono"><strong><a href="alumnregdatos.php"><img src="prueba/botonATRAS.gif" width="75" height="62" border="0"></a></strong></font></p></td>
</tr>
</table>
<?
exit;}
else
{
$sql1 = "INSERT INTO inscripcion (nombre, apellido, cedula, fecha_nac, direccion, año_ingreso, carrera, facultad) ";
$sql1 .= "VALUES ('$ninombre','$niapellido','$cedulani','$nifechan','$nidireccion','$niaño','$carrera','$facni')";
$result1 = mysql_query($sql1);
$sql = "INSERT INTO boucher (num_boucher, cedula_alum, fecha) ";
$sql .= "VALUES ('$nboucher','$cedulani', '$fecha')";
$result = mysql_query($sql);
echo "¡Gracias! Hemos recibido sus datos.\n<br>";
echo "<br>";
$consulta="select nombre, apellido,cedula,fecha_nac,direccion,carrera,facultad,año_ingreso from inscripcion where cedula='".$cedulani."'";
$resultado=mysql_query($consulta);
$num_resultados=mysql_num_rows($resultado);
$fila=mysql_fetch_array($resultado);
?>
<p> </p>
<p align="center">Nombres:
<input name="nombre" type="text" value="<? echo $fila["nombre"] ?>" >
Apellidos:
<input name="nombre" type="text" value="<? echo $fila["apellido"] ?>" >
Cedula:
<input name="nombre" type="text" value="<? echo $fila["cedula"] ?>" >
<br>
</p>
<p align="center">Fecha De Nacimiento:
<input name="nombre" type="text" value="<? echo $fila["fecha_nac"] ?>" >
</p>
<p align="center"> Dirección:
<textarea name="nombre"><? echo $fila["direccion"] ?></textarea>
<br>
<img src="prueba/index_clip_image001.gif" width="703" height="6"></p>
<p align="center"> Facultad:
<input name="nombre" type="text" value="<? echo $fila["facultad"] ?>" >
Carrera:
<input name="nombre" type="text" value="<? echo $fila["carrera"] ?>" >
Año De Ingreso:
<input name="nombre" type="text" value="<? echo $fila["año_ingreso"] ?>" >
<br>
<br>
</p>
<?
$consulta2="select num_boucher from boucher where cedula_alum='".$cedulani."'";
$resultado2=mysql_query($consulta2);
$num_resultados2=mysql_num_rows($resultado2);
$fila2=mysql_fetch_array($resultado2);
?>
<div align="center">Numero Del Boucher:<strong> <input name="nboucher" type="text" value="<? echo $fila2["num_boucher"] ?>" >
</strong><br>
<img src="prueba/index_clip_image001.gif" width="703" height="6"><br>
<br>
<br>
<?
$dia=date("l");
if ($dia=="Monday") $dia="Lunes";
if ($dia=="Tuesday") $dia="Martes";
if ($dia=="Wednesday") $dia="Miércoles";
if ($dia=="Thursday") $dia="Jueves";
if ($dia=="Friday") $dia="Viernes";
if ($dia=="Saturday") $dia="Sabado";
if ($dia=="Sunday") $dia="Domingo";
$dia2=date("d");
$mes=date("F");
if ($mes=="January") $mes="Enero";
if ($mes=="February") $mes="Febrero";
if ($mes=="March") $mes="Marzo";
if ($mes=="April") $mes="Abril";
if ($mes=="May") $mes="Mayo";
if ($mes=="June") $mes="Junio";
if ($mes=="July") $mes="Julio";
if ($mes=="August") $mes="Agosto";
if ($mes=="September") $mes="Setiembre";
if ($mes=="October") $mes="Octubre";
if ($mes=="November") $mes="Noviembre";
if ($mes=="December") $mes="Diciembre";
$ano=date("Y");
echo "$dia $dia2 de $mes de $ano";
echo "<br><strong>Importante: Por Favor Imprima su Recibo de Inscripcion.</strong><br>";
?> </p>
<table width="200" border="0">
<tr>
<td><div align="center"><img src="prueba/lexmark---impresora.gif"></div></td>
</tr>
</table>
<div id="divButtons" name="divButtons">
<input type="button" value = "Imprimir" onclick="printPage()" style="font:bold 11px verdana;color:yellow;background-color:#32AFDE;">
</div> <?
}
?>
disculpa lo desordenado en la programacion pero soy nuevo en esto. agradecere enormemente tu enseñanza