Ver Mensaje Individual
  #3 (permalink)  
Antiguo 06/06/2014, 16:42
c_rubio_acevedo
 
Fecha de Ingreso: junio-2014
Mensajes: 14
Antigüedad: 9 años, 10 meses
Puntos: 0
Respuesta: Al grabar con sesiones distintas me guarda el mismo consecutivo

antes que nada muchas gracias por contestar tan rapido a mi consulta, como decia una vez que grabo formulario me incrementa bien el consecutivo del oficio pero si hago lo mismo al mismo iniciando sesiones distintas al mismo tiempo desde mi pc con explore y chrome, le doy grabar y al revisar la tabla tbloficios me graba el mismo consecutivo para ambos usuarios.

este es el codigo:
Código PHP:
Ver original
  1. <?php require_once('Connections/conexiontribunal.php'); ?>
  2. <?php
  3.  
  4. if (!function_exists("GetSQLValueString")) {
  5. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  6. {
  7.   if (PHP_VERSION < 6) {
  8.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  9.   }
  10.  
  11.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  12.  
  13.   switch ($theType) {
  14.     case "text":
  15.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  16.       break;    
  17.     case "long":
  18.     case "int":
  19.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  20.       break;
  21.     case "double":
  22.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  23.       break;
  24.     case "date":
  25.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  26.       break;
  27.     case "defined":
  28.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  29.       break;
  30.   }
  31.   return $theValue;
  32. }
  33. }
  34.  
  35. $editFormAction = $_SERVER['PHP_SELF'];
  36. if (isset($_SERVER['QUERY_STRING'])) {
  37.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  38. }
  39.  
  40. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  41.   $insertSQL = sprintf("INSERT INTO tbloficios (num_oficio, fech_oficio, rit_causa, estado_oficio, destinatario_oficio, ciudad, intfuncionario) VALUES (%s, %s, %s, %s, %s, %s, %s)",
  42.                        GetSQLValueString($_POST['num_oficio'], "int"),
  43.                        GetSQLValueString($_POST['fech_oficio'], "text"),
  44.                        GetSQLValueString($_POST['rit_causa'], "text"),
  45.                        GetSQLValueString($_POST['estado_oficio'], "text"),
  46.                        GetSQLValueString($_POST['destinatario_oficio'], "text"),
  47.                        GetSQLValueString($_POST['ciudad'], "text"),
  48.                        GetSQLValueString($_POST['intfuncionario'], "text"));
  49.  
  50.   mysql_select_db($database_conexiontribunal, $conexiontribunal);
  51.   $Result1 = mysql_query($insertSQL, $conexiontribunal) or die(mysql_error());
  52.  
  53.   $insertGoTo = "oficio_crea.php";
  54.   if (isset($_SERVER['QUERY_STRING'])) {
  55.     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  56.     $insertGoTo .= $_SERVER['QUERY_STRING'];
  57.   }
  58. // header(sprintf("Location: %s", $insertGoTo));
  59. }
  60.  
  61. mysql_select_db($database_conexiontribunal, $conexiontribunal);
  62. $query_mayor_oficio = "SELECT tbloficios.num_oficio FROM tbloficios ORDER BY tbloficios.num_oficio DESC limit 1";
  63. $mayor_oficio = mysql_query($query_mayor_oficio, $conexiontribunal) or die(mysql_error());
  64. $row_mayor_oficio = mysql_fetch_assoc($mayor_oficio);
  65. $totalRows_mayor_oficio = mysql_num_rows($mayor_oficio);
  66.  
  67.  
  68. $mayor = $row_mayor_oficio;
  69.  
  70.  
  71.  
  72. mysql_select_db($database_conexiontribunal, $conexiontribunal);
  73. $query_Detlle_oficios = "SELECT *  FROM tbloficios";
  74. $Detlle_oficios = mysql_query($query_Detlle_oficios, $conexiontribunal) or die(mysql_error());
  75. $row_Detlle_oficios = mysql_fetch_assoc($Detlle_oficios);
  76. $totalRows_Detlle_oficios = mysql_num_rows($Detlle_oficios);
  77.  
  78.  
  79.  
  80.  
  81.  if ((isset($_SESSION['MM_Username'])) && ($_SESSION['MM_Username'] != ""))
  82.  
  83.   {
  84.      
  85.     $nom_funcionario = ObtenerNombreUsuario($_SESSION['MM_id_funcionario']);
  86.   }
  87.  
  88.    
  89.    
  90. ?>
  91.  
  92. <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  93.              <table width="363" height="305" align="center">
  94.                <tr valign="baseline">
  95.                  <td width="129" height="90" align="center" valign="middle" nowrap="nowrap" bgcolor="#999999"><p><strong>N° OFICIO:   </strong></p>
  96.                  <p>&nbsp;</p></td>
  97.                     <?php
  98.                
  99.                        $mayor= $row_mayor_oficio['num_oficio']+1;
  100.                      ?>
  101.                  
  102.                  <td width="222" valign="baseline" bgcolor="#999999">   <p>&nbsp;</p>
  103.                    <p>
  104.                      <input name="num_oficio" type="hidden" value="<?php echo $mayor; ?>""  align="center" size="10" height= "60" />
  105.                  </p>
  106.                  <p>&nbsp;</p></td>
  107.                </tr>
  108.                
  109.                <tr valign="baseline">
  110.                  <td align="left" nowrap="nowrap" bgcolor="#999999">Autor:</td>
  111.                    <td bgcolor="#999999"><input type="text" name="intfuncionario" value="<?php echo $nom_funcionario; ?>" readonly="readonly" size="32" />
  112.                 </td>
  113.                </tr>
  114.                
  115.                <tr valign="baseline">
  116.                  <td align="left" nowrap="nowrap" bgcolor="#999999">Fecha:</td>
  117.                  <td bgcolor="#999999"><input type="text" name="fech_oficio" value="<?php echo date("d/m/Y"); ?>" readonly="readonly" size="32" />
  118.                  </td>
  119.                </tr>
  120.                
  121.                  
  122.                <tr valign="baseline">
  123.                  <td align="left" nowrap="nowrap" bgcolor="#999999">Rit Causa:</td>
  124.                  <td bgcolor="#999999"><input name="rit_causa" type="text" value="" size="20" /td />
  125.                </td>
  126.                </tr>
  127.                
  128.                <tr valign="baseline">
  129.                  <td align="left" nowrap="nowrap" bgcolor="#999999">Destinatario:</td>
  130.                  <td bgcolor="#999999"><label for="select"></label>
  131.                    <select name="destinatario_oficio" id="select">
  132.                      <option></option>
  133.                      <option>Corte de Apelaciones</option>
  134.                      <option>Corte Suprema</option>
  135.                      <option>Tribunal de Familia</option>
  136.                      <option>Tribunal de Garantia</option>
  137.                      <option>Tribunal Civil</option>
  138.                      <option>Tribunal en lo Penal</option>
  139.                      <option>Tribunal del Trabajo</option>
  140.                      <option>Tribunal de Letras</option>
  141.                      <option>Centro de Reinsercion</option>
  142.                    </select></td>
  143.                </tr>
  144.                              
  145.                 <tr valign="baseline">
  146.                  <td align="left" nowrap="nowrap" bgcolor="#999999">Ciudad:</td>
  147.                  <td bgcolor="#999999"><label for="select"></label>
  148.                    <select name="ciudad" id="select" >
  149.                      <option></option>
  150.                      <option>Los Angeles</option>
  151.                      <option>Mulchen</option>
  152.                      <option>Coronel</option>
  153.                      <option>Concepcion</option>
  154.                      <option>Temuco</option>
  155.                      <option>Valdivia</option>
  156.                      <option>La Serena</option>
  157.                      <option>Viña del Mar</option>
  158.                      <option>Valparaiso</option>
  159.                      <option>Santiago</option>
  160.                  </select></td>
  161.                </tr>
  162.              
  163.              
  164.                <tr valign="baseline">
  165.                  <td align="right" nowrap="nowrap" bgcolor="#999999">&nbsp;</td>
  166.                  <td bgcolor="#999999"><input type="submit" value="Crea Oficio" />
  167.                        <input type="reset" name="button" id="button" value="Limpiar Formulario" /></td>
  168.                </tr>
  169.              </table>
  170.              <p>
  171.                
  172.                <input type="hidden" name="estado_oficio" value="Pendiente" />
  173.                <input type="hidden" name="MM_insert" value="form1" />
  174.              </p>
  175.            </form>
  176.            <p>&nbsp;</p>
  177. <p>&nbsp;</p>
  178.            <p>&nbsp;</p>
  179. <?php
  180. mysql_free_result($mayor_oficio);
  181.  
  182.  
  183. mysql_free_result($Detlle_oficios);

Última edición por Triby; 06/06/2014 a las 18:21 Razón: Código en highlight