Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/11/2012, 10:17
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 12 años, 5 meses
Puntos: 10
Pasar variable después hacer un update.

Hola, buenas tardes quisiera saber como puedo hacer para después de hacer un update de un formulario me llevara una variable llamada num_aparato a otra pagina llamada menu3.php.En el interior del cod lo detallo.

Aquí el cod:

Código Javascript:
Ver original
  1. <?php require_once('Connections/conexion.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $editFormAction = $_SERVER['PHP_SELF'];
  35. if (isset($_SERVER['QUERY_STRING'])) {
  36.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  37. }
  38.  
  39. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form3")) {
  40.   $updateSQL = sprintf("UPDATE ap_usuarios SET MODELO=%s, MARCA=%s, APARATO=%s, COD_APARATO=%s, GRUPO=%s, NUM_PRODUCTO=%s, REVISION=%s, FD=%s, NUM_SERIE=%s, DISTRIBUIDOR=%s, ASEGURADORA=%s, FECHA_COMPRA=%s, INICIO_GARANTIA=%s, FIN_GARANTIA=%s WHERE NUM_APARATO=%s",
  41.                        GetSQLValueString($_POST['MODELO'], "text"),
  42.                        GetSQLValueString($_POST['MARCA'], "text"),
  43.                        GetSQLValueString($_POST['APARATO'], "text"),
  44.                        GetSQLValueString($_POST['COD_APARATO'], "text"),
  45.                        GetSQLValueString($_POST['GRUPO'], "text"),
  46.                        GetSQLValueString($_POST['NUM_PRODUCTO'], "text"),
  47.                        GetSQLValueString($_POST['REVISION'], "text"),
  48.                        GetSQLValueString($_POST['FD'], "text"),
  49.                        GetSQLValueString($_POST['NUM_SERIE'], "text"),
  50.                        GetSQLValueString($_POST['DISTRIBUIDOR'], "text"),
  51.                        GetSQLValueString($_POST['ASEGURADORA'], "text"),
  52.                        GetSQLValueString($_POST['FECHA_COMPRA'], "date"),
  53.                        GetSQLValueString($_POST['INICIO_GARANTIA'], "date"),
  54.                        GetSQLValueString($_POST['FIN_GARANTIA'], "date"),
  55.                        GetSQLValueString($_POST['NUM_APARATO'], "int"));
  56.  
  57.   mysql_select_db($database_conexion, $conexion);
  58.   $Result1 = mysql_query($updateSQL, $conexion) or die(mysql_error());
  59.  
  60.  $updateGoTo = "menu3.php";///Aquí es donde quiero que me lleve después del update con la variable $num_aparato/////
  61.   if (isset($_SERVER['QUERY_STRING'])) {
  62.     $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
  63.     $updateGoTo .= $_SERVER['QUERY_STRING'];
  64.   }
  65.   header(sprintf("Location: %s", $updateGoTo));
  66. }
  67. $num_aparato=$_GET['ID'];
  68. mysql_select_db($database_conexion, $conexion);
  69. $query_Recordset1 = "SELECT * FROM ap_usuarios where num_aparato = '$num_aparato'";
  70. $Recordset1 = mysql_query($query_Recordset1, $conexion) or die(mysql_error());
  71. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  72. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  73. ?>
  74. <form method="post" name="form3" action="<?php echo $editFormAction; ?>">
  75. <table width="100%">
  76.   <tr>
  77.     <td>Aparato</td>
  78.     <td><input name="APARATO" type="text" value="<?php echo $row_Recordset1['APARATO']; ?>" /></td>
  79.     <td>Modelo</td>
  80.     <td><input name="MODELO" type="text" value="<?php echo $row_Recordset1['MODELO']; ?>" /></td>
  81.     <td>NºSerie</td>
  82.     <td><input name="NUM_SERIE" type="text" value="<?php echo $row_Recordset1['NUM_SERIE']; ?>" /></td>
  83.   </tr>
  84.   <tr>
  85.     <td>Marca</td>
  86.     <td><input name="MARCA" type="text" value="<?php echo $row_Recordset1['MARCA']; ?>" /></td>
  87.     <td>Cod/12Nc</td>
  88.     <td><input name="NUM_PRODUCTO" type="text" value="<?php echo $row_Recordset1['NUM_PRODUCTO']; ?>" /></td>
  89.     <td>Revisión</td>
  90.     <td><input name="REVISION" type="text" /></td>
  91.   </tr>
  92.   <input type="hidden" name="MM_update" value="form3">
  93.   <input type="hidden" name="NUM_APARATO" value="<?php echo $row_Recordset1['NUM_APARATO']; ?>">
  94.   </table>
  95.   </form>
  96. <?php
  97. mysql_free_result($Recordset1);
  98. ?>

Gracias y un saludo.