Ver Mensaje Individual
  #8 (permalink)  
Antiguo 07/06/2013, 11:57
Avatar de nexus44
nexus44
 
Fecha de Ingreso: octubre-2012
Ubicación: Piura
Mensajes: 108
Antigüedad: 11 años, 6 meses
Puntos: 1
Respuesta: Eliminacion logica PHP A/D

mi bd : usuarios

CREATE TABLE IF NOT EXISTS `usuarios` (
`usuario_id` int(12) unsigned NOT NULL AUTO_INCREMENT,
`nombre_user` varchar(60) NOT NULL,
`nombre` varchar(40) NOT NULL,
`apellido` varchar(40) NOT NULL,
`password` varchar(40) NOT NULL,
`email` varchar(40) NOT NULL,
`fecha` date NOT NULL,
`control` enum('admin','user','premium') NOT NULL DEFAULT 'user',
`estado` enum('a','i') NOT NULL,
PRIMARY KEY (`usuario_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;



Una vez dado SI , va ir a :


eliminar_user.php

entonces , aqui es donde debo trabajar lo que es la eliminacion logica ; pero como asignarlo.
Código PHP:
Ver original
  1. <?php require_once('Connections/con_usuarios.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. if ((isset($_GET['nombre_user'])) && ($_GET['nombre_user'] != "")) {
  35.   $deleteSQL = sprintf("DELETE FROM usuarios WHERE nombre_user=%s",
  36.                        GetSQLValueString($_GET['nombre_user'], "text"));
  37.  
  38.   mysql_select_db($database_con_usuarios, $con_usuarios);
  39.   $Result1 = mysql_query($deleteSQL, $con_usuarios) or die(mysql_error());
  40.  
  41.   $deleteGoTo = "listado_users.php";
  42.   if (isset($_SERVER['QUERY_STRING'])) {
  43.     $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
  44.     $deleteGoTo .= $_SERVER['QUERY_STRING'];
  45.   }
  46.   header(sprintf("Location: %s", $deleteGoTo));
  47. }
  48.  
  49. $colname_usuario = "-1";
  50. if (isset($_GET['nombre_user'])) {
  51.   $colname_usuario = $_GET['nombre_user'];
  52. }
  53. mysql_select_db($database_con_usuarios, $con_usuarios);
  54. $query_usuario = sprintf("SELECT * FROM usuarios WHERE nombre_user = %s", GetSQLValueString($colname_usuario, "text"));
  55. $usuario = mysql_query($query_usuario, $con_usuarios) or die(mysql_error());
  56. $row_usuario = mysql_fetch_assoc($usuario);
  57. $totalRows_usuario = mysql_num_rows($usuario);
  58. ?>
  59. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  60. <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/base.dwt.php" codeOutsideHTMLIsLocked="false" -->
  61. <head>
  62. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  63. <!-- InstanceBeginEditable name="doctitle" -->
  64. <title>Documento sin título</title>
  65. <!-- InstanceEndEditable -->
  66. <style type="text/css">
  67. <!--
  68. body {
  69.     margin-top: 0px;
  70.     background-image: url(fondo.jpg);
  71.     background-repeat: repeat-x;
  72. }
  73. -->
  74. </style>
  75. <!-- InstanceBeginEditable name="head" -->
  76. <!-- InstanceEndEditable -->
  77. </head>
  78.  
  79. <body>
  80. <table width="80%" border="0" align="center">
  81.   <tr>
  82.     <td align="center" bgcolor="#6DC1F0"><h1> control de usuarios<br />
  83.     </h1></td>
  84.   </tr>
  85.   <tr>
  86.     <td align="center" bgcolor="#FFFFFF"><!-- InstanceBeginEditable name="contenido" -->reemplazar<!-- InstanceEndEditable --></td>
  87.   </tr>
  88. </table>
  89. </body>
  90. <!-- InstanceEnd --></html>
  91. <?php
  92. ?>
__________________

"Nuestra capacidad se aleja de la Humanidad"

Última edición por nexus44; 07/06/2013 a las 12:05 Razón: easy