Ver Mensaje Individual
  #2 (permalink)  
Antiguo 29/01/2014, 15:24
Karen_mBrK
 
Fecha de Ingreso: enero-2014
Mensajes: 127
Antigüedad: 10 años, 3 meses
Puntos: 2
Respuesta: Problemas con modificar y eliminar datos mysql.

Aquí el código de modificación:

<?php require_once('Connections/Pharma.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE usuarios SET Nombre=%s, Apellido_P=%s, Apellido_M=%s, RFC=%s, Telefono=%s, Celular=%s, email=%s, Plaza=%s, Fecha_Inicio=%s, Domicilio=%s WHERE CURP=%s",
GetSQLValueString($_POST['Nombre'], "text"),
GetSQLValueString($_POST['Apellido_P'], "text"),
GetSQLValueString($_POST['Apellido_M'], "text"),
GetSQLValueString($_POST['RFC'], "text"),
GetSQLValueString($_POST['Telefono'], "int"),
GetSQLValueString($_POST['Celular'], "int"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['Plaza'], "text"),
GetSQLValueString($_POST['Fecha_Inicio'], "date"),
GetSQLValueString($_POST['Domicilio'], "text"),
GetSQLValueString($_POST['CURP'], "text"));

mysql_select_db($database_Pharma, $Pharma);
$Result1 = mysql_query($updateSQL, $Pharma) or die(mysql_error());

$updateGoTo = "modif_ok.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}

$colname_modificar = "-1";
if (isset($_GET['CURPm'])) {
$colname_modificar = $_GET['CURPm'];
}


mysql_select_db($database_Pharma, $Pharma);
$query_modificar = sprintf("SELECT usuarios.CURP, Nombre, Apellido_P, Apellido_M, RFC, Telefono, Celular, email, Plaza, Fecha_Inicio, nomina, ns_celular, ns_tablet, ns_pc, domicilio FROM usuarios inner join login inner join pagos inner join equipo_trabajo WHERE usuarios.CURP = %s", GetSQLValueString($colname_modificar, "text"));
$modificar = mysql_query($query_modificar, $Pharma) or die(mysql_error());
$row_modificar = mysql_fetch_assoc($modificar);
$totalRows_modificar = mysql_num_rows($modificar);
?>

<table width="544" height="661" border="0" align="center">
<tr>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">CURP:</td>
<td><input type="text" name="CURP" value="<?php echo $row_modificar['CURP']; ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nombre:</td>
<td><input type="text" name="Nombre" value="<?php echo htmlentities($row_modificar['Nombre'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Apellido_P:</td>
<td><input type="text" name="Apellido_P" value="<?php echo htmlentities($row_modificar['Apellido_P'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Apellido_M:</td>
<td><input type="text" name="Apellido_M" value="<?php echo htmlentities($row_modificar['Apellido_M'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">RFC:</td>
<td><input type="text" name="RFC" value="<?php echo htmlentities($row_modificar['RFC'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Telefono:</td>
<td><input type="text" name="Telefono" value="<?php echo htmlentities($row_modificar['Telefono'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Celular:</td>
<td><input type="text" name="Celular" value="<?php echo htmlentities($row_modificar['Celular'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><input type="text" name="email" value="<?php echo htmlentities($row_modificar['email'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Plaza:</td>
<td><input type="text" name="Plaza" value="<?php echo htmlentities($row_modificar['Plaza'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fecha_Inicio:</td>
<td><input type="text" name="Fecha_Inicio" value="<?php echo htmlentities($row_modificar['Fecha_Inicio'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Domicilio:</td>
<td><input type="text" name="Domicilio" value="<?php echo $row_modificar['domicilio']; ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Actualizar registro" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="CURP" value="<?php echo $row_modificar['CURP']; ?>" />
</form>
<p>&nbsp;</p></td>
<td>&nbsp;</td>
</tr>
</table>
<?php
mysql_free_result($modificar);

?>