<?php require_once('Connections/AbogadosSC.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;
}
}

if ((isset($_GET['nombre'])) && ($_GET['nombre'] != "")) {
  $deleteSQL = sprintf("DELETE FROM formulario WHERE nombre=%s",
                       GetSQLValueString($_GET['nombre'], "text"));

  mysql_select_db($database_AbogadosSC, $AbogadosSC);
  $Result1 = mysql_query($deleteSQL, $AbogadosSC) or die(mysql_error());

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

if ((isset($_GET['nombre'])) && ($_GET['nombre'] != "")) {
  $deleteSQL = sprintf("DELETE FROM formulario WHERE nombre=%s",
                       GetSQLValueString($_GET['nombre'], "text"));

  mysql_select_db($database_AbogadosSC, $AbogadosSC);
  $Result1 = mysql_query($deleteSQL, $AbogadosSC) or die(mysql_error());

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

mysql_select_db($database_AbogadosSC, $AbogadosSC);
$query_Eliminar = "SELECT * FROM formulario";
$Eliminar = mysql_query($query_Eliminar, $AbogadosSC) or die(mysql_error());
$row_Eliminar = mysql_fetch_assoc($Eliminar);
$totalRows_Eliminar = mysql_num_rows($Eliminar);
?>
<!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=utf-8" />
<title>Documento sin título</title>
</head>

<body>
</body>
</html>
<?php
mysql_free_result($Eliminar);
?>
