Ver Mensaje Individual
  #8 (permalink)  
Antiguo 04/04/2006, 05:06
Avatar de Bytevamp
Bytevamp
 
Fecha de Ingreso: junio-2005
Ubicación: /var/www/
Mensajes: 789
Antigüedad: 18 años, 10 meses
Puntos: 7
A ver prueba con esto:
Código PHP:
<?php

$centro 
$_POST["centro"];
$paciente $_POST["paciente"];
$iniciales $_POST["iniciales"];

include 
"conexion.php";

if( 
$paciente != "" ){

$query 'SELECT iniciales FROM pacientes WHERE paciente = '.$paciente.' AND centro = '.$centro;

$result mysql_query($query);

$row mysql_fetch_array($result);

if (
mysql_num_rows($result)) { ?>

<script language="JavaScript" type="text/javascript">
var cadena = "<?php echo "El paciente ".$row['iniciales']." ya esta registrado"?>";
alert(cadena);
</script>

<?

mysql_free_result
($result);


} else { 
// ES Q NO ESTA REGISTRADO


$query 'INSERT INTO pacientes (centro,paciente,iniciales) VALUES("'.$centro.'","'.$paciente.'","'.$iniciales .'")';

$result mysql_query($query);

header("Location:formulario1.php?paciente=$paciente");

}
// if
?>
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/crd.css" rel="stylesheet" type="text/css">
<title>Estudios TPV-IQ</title>
<script language="JavaScript" type="text/javascript">
function enviar(){
if ( (document.paciente.centro.value == "" ) || (document.paciente.paciente.value == "" ) || (document.paciente.iniciales.value == "" ) ){

alert("Faltan Datos");

} else { document.paciente.submit(); }

}

function reenviar(){

document.location.href = "formulario1.php?paciente=<?php echo $paciente?>";

}
</script>
</head>
<body>
<br>
<div class="cabecera" style="font-size:19px;">Estudios TPV-IQ</div>
<br>
<div style="width:400px;">
<p>Cociente Inhibitorio Virtual de Tipranavir
como factor pronóstico de respuesta virológica en tratamientos
antirretrovirales de rescate.</p>
</div>
<br>
<p style="font-size:16px;">Cuaderno de Recogida de Datos</p>
<br><form name="paciente" action="index.php" method="post">
<table cellpadding="0" cellspacing="0" style=" margin-left:25px; padding-left:25px; padding-right:25px;border:#0066CC dashed; border-width:1px; padding-bottom:10px; padding-top:10px;">
<tr>
<td align="right">N&uacute;mero del centro:</td>
<td style="padding-left:15px;"><input name="centro" maxlength="2" style="width:40px; height:17px;"></td>
<td>[2 Digitos]</td>
</tr>
<tr>
<td align="right">N&uacute;mero del paciente:</td>
<td style="padding-left:15px;"><input name="paciente" maxlength="3" style="width:40px; height:17px;"></td>
<td>[3 Digitos]</td>
</tr>
<tr>
<td align="right">Iniciales del paciente:</td>
<td style="padding-left:15px;"><input name="iniciales" maxlength="4" style="width:40px; height:17px;"></td>
<td>[4 Digitos]</td>
</tr>
<tr>
<td style="padding-left:15px;" colspan="3" align="right"><div onClick="javascript:enviar();"><img src="images/enviar.gif" alt=""></div></td>
</tr>
</table>
</form>
</body>
</html>
Espero que te sirva.

Saludos.
__________________
"zankius veri mach" a todos los que me habeis ayudado.
carteles para inmobiliarias || alquiler de coches