Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/03/2008, 19:48
RSMCPROG
 
Fecha de Ingreso: febrero-2008
Mensajes: 32
Antigüedad: 16 años, 2 meses
Puntos: 0
Exclamación hola una pregunta

tengo una duda
lo que pasa es que tengo el siguiente codigo creado en dreamweaver pero no se como hacer para que me valide mi rpe...la cuestion es que si quiero dar de alta un trabajador y deseo dar de alta otro con el mismo rpe no deje que lo haga
que me muestre un mensaje como

"ese rpe ya esta siendo utilizado"

dado el hecho de qeu no se hacerlo actualmente lo estoy trabajando con el error que marca automaticamente el mysql...pero no es atractivo para el usuario y como esta en ingles hay usuarios que no hablan ingles y podrian no entender por lo tanto necesito que alguien me diga como puedo hacer que me valide el rpe

aqui les muestro mi codigo

Código PHP:
<?php require_once('Connections/rommy.php'); ?>
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO trabajador (rpe, nombret, numafi, clavett, clavets) VALUES (%s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['rpe'], "text"),
                       
GetSQLValueString($_POST['nombret'], "text"),
                       
GetSQLValueString($_POST['numafi'], "text"),
                       
GetSQLValueString($_POST['clavett'], "int"),
                       
GetSQLValueString($_POST['clavets'], "int"));

  
mysql_select_db($database_rommy$rommy);
  
$Result1 mysql_query($insertSQL$rommy) or die(mysql_error());
}

mysql_select_db($database_rommy$rommy);
$query_Recordset1 "SELECT * FROM tipotrabajador";
$Recordset1 mysql_query($query_Recordset1$rommy) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);

mysql_select_db($database_rommy$rommy);
$query_Recordset2 "SELECT * FROM tiposeguro";
$Recordset2 mysql_query($query_Recordset2$rommy) or die(mysql_error());
$row_Recordset2 mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 mysql_num_rows($Recordset2);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form method="post" name="form1" action="<?php echo $editFormAction?>">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">RPE:</td>
      <td><input type="text" name="rpe" value="" size="4" maxlength="5"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Nombre de Trabajador :</td>
      <td><input type="text" name="nombret" value="" size="30"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Número de afiliación :</td>
      <td><input type="text" name="numafi" value="" size="20"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Tipo de Contrato :</td>
      <td><select name="clavett">
        <?php 
do {  
?>
        <option value="<?php echo $row_Recordset1['clavett']?>" ><?php echo $row_Recordset1['titr']?></option>
        <?php
} while ($row_Recordset1 mysql_fetch_assoc($Recordset1));
?>
      </select>
      </td>
    <tr>
    <tr valign="baseline">
      <td nowrap align="right">Tipo de Seguro:</td>
      <td><select name="clavets">
        <?php 
do {  
?>
        <option value="<?php echo $row_Recordset2['clavets']?>" ><?php echo $row_Recordset2['tise']?></option>
        <?php
} while ($row_Recordset2 mysql_fetch_assoc($Recordset2));
?>
      </select>
      </td>
    <tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="Insert record"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result
($Recordset1);

mysql_free_result($Recordset2);
?>