Ver Mensaje Individual
  #12 (permalink)  
Antiguo 22/02/2008, 09:16
Avatar de Sensorium
Sensorium
 
Fecha de Ingreso: julio-2007
Ubicación: Montevideo-Uruguay
Mensajes: 207
Antigüedad: 16 años, 10 meses
Puntos: 7
Re: un empujon porfavor

si, en el else puedes poner una alerta pero no de esa forma, te sugiero que lo retornes a la pagina del formulario, y el mensaje de error lo pones allí haz algo como esto:

Código PHP:
<?php

$bd
=mysql_connect("localhost","root","1234") or die ("No conecta");
mysql_select_db("sis_notas");

$opt=$_POST["opt"];

if (
$opt==1)
{
$codigo=$_POST["codigo"];
$pass=$_POST["pass"];
$sql=mysql_query("SELECT cod_alum FROM alumnos WHERE cod_alum='$codigo'");
    if(
mysql_num_rows($sql)!=0)
        {
            
header("location:estudiantes2.php");
        }
        else
        {
            
$_POST=array();
            
header("location:$_SERVER['PHP_SELF']?msg=1");    
        }

}
else
{
?>


<html>

<head>

<title>Control de Notas On-Line</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>


<script language="javascript">
function verifica()
{
if (login.pass.value=="")
{
alert ("Ingrese una contraseña");
return;
};

login.opt.value=1;
login.submit();
}
function limpia()
{
login.codigo=""
login.pass=""
}
</script>

<body>
<form name="login" method="POST" action='<?=$_SERVER[PHP_SELF]?>'>
<input type="hidden" name="opt">

<div align="center">

<table width="280" border="0">

<tr>

<td colspan="2"><div align="center"></div></td>

</tr>

<tr>

<td colspan="2"><div align="center"><? if($_GET[msg]==1){ print "Datos Erroneos"; }?></div> 
  <div align="center">Control de Notas</div></td>

</tr>

<tr>

<td width="126"><div align="center">ID:</div></td>

<td width="144"><div align="center">

<input type="text" name="codigo">

</div></td>

</tr>

<tr>

<td><div align="center">Contrase&ntilde;a:</div></td>

<td><div align="center">

<input type="password" name="pass">

</div></td>

</tr>

<tr>

<td><div align="center">

<input type="submit" name="Aceptar" value="Aceptar" onClick="verifica()">

</div></td>

<td><div align="center">

<input type="submit" name="limpiar" value="Limpiar">

</div></td>

</tr>

</table>

</div>
</form>

</body>

</html>
<? }?>
si te fijas puse un IF en el form