<?php require_once('Connections/conn.php'); ?>

<style type="text/css">
  body {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
  .bd {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
  .tbl {
    background-color: #FFFFFF;
  }
  a:link { 
    background-color: #FFFFFF01;
    color: #FF0000;
    font-family: Arial;
    font-size: 12px;
  }
  a:active { 
    background-color: #FFFFFF01;
    color: #0000FF;
    font-family: Arial;
    font-size: 12px;
  }
  a:visited { 
    background-color: #FFFFFF01;
    color: #800080;
    font-family: Arial;
    font-size: 12px;
  }
  .hr {
    background-color: #336699;
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:link {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:active {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:visited {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  .dr {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
  .sr {
    background-color: #FFFFCF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
</style>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO preinscripciones (tipodoc, cedula, nacionalidad, fechanac, apellidos, nombres, genero, edocivil, tlfcasa, tlfoficina, tlfcelular, email, id_programa, nom_programa, id_sede, nom_sede, fecha_preins, observaciones, status) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['tipodoc'], "text"),
                       GetSQLValueString($_POST['cedula'], "text"),
                       GetSQLValueString($_POST['nacionalidad'], "text"),
                       GetSQLValueString($_POST['fechanac'], "date"),
                       GetSQLValueString($_POST['apellidos'], "text"),
                       GetSQLValueString($_POST['nombres'], "text"),
                       GetSQLValueString($_POST['genero'], "text"),
                       GetSQLValueString($_POST['edocivil'], "text"),
                       GetSQLValueString($_POST['tlfcasa'], "text"),
                       GetSQLValueString($_POST['tlfoficina'], "text"),
                       GetSQLValueString($_POST['tlfcelular'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['id_programa'], "text"),
                       GetSQLValueString($_POST['nom_programa'], "text"),
                       GetSQLValueString($_POST['id_sede'], "text"),
                       GetSQLValueString($_POST['nom_sede'], "text"),
                       GetSQLValueString($_POST['fecha_preins'], "date"),
                       GetSQLValueString($_POST['observaciones'], "text"),
                       GetSQLValueString($_POST['status'], "text"));

  mysql_select_db($database_conn, $conn);
  $Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());
}
?>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table class="tbl" border="0" cellspacing="1" cellpadding="5"width="84%">
    
    <tr>
      <td colspan="4" class="dr">Datos Personales </td>
    </tr>
    <tr>
      <td width="18%" class="dr">Tipo de Documento        </td>
      <td width="18%" class="dr">C&eacute;dula:      </td>
      <td width="27%" class="dr">Nombres</td>
      <td width="37%" class="dr">Apellidos</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="tipodoc" maxlength="1" value="<?php echo str_replace('"', '&quot;', trim($row["tipodoc"])) ?>"></td>
      <td class="dr"><input type="text" name="cedula" maxlength="12" value="<?php echo str_replace('"', '&quot;', trim($row["cedula"])) ?>"></td>
      <td class="dr"><input type="text" name="nacionalidad" maxlength="10" value="<?php echo str_replace('"', '&quot;', trim($row["nacionalidad"])) ?>"></td>
      <td class="dr"><input type="text" name="fechanac" value="<?php echo str_replace('"', '&quot;', trim($row["fechanac"])) ?>"></td>
    </tr>
    <tr>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="apellidos" maxlength="50" value="<?php echo str_replace('"', '&quot;', trim($row["apellidos"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="nombres" maxlength="50" value="<?php echo str_replace('"', '&quot;', trim($row["nombres"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="genero" maxlength="10" value="<?php echo str_replace('"', '&quot;', trim($row["genero"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="edocivil" maxlength="10" value="<?php echo str_replace('"', '&quot;', trim($row["edocivil"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="tlfcasa" maxlength="20" value="<?php echo str_replace('"', '&quot;', trim($row["tlfcasa"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="tlfoficina" maxlength="20" value="<?php echo str_replace('"', '&quot;', trim($row["tlfoficina"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="tlfcelular" maxlength="20" value="<?php echo str_replace('"', '&quot;', trim($row["tlfcelular"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="email" maxlength="50" value="<?php echo str_replace('"', '&quot;', trim($row["email"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="id_programa" maxlength="5" value="<?php echo str_replace('"', '&quot;', trim($row["id_programa"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="id_sede" maxlength="2" value="<?php echo str_replace('"', '&quot;', trim($row["id_sede"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="nom_sede" maxlength="40" value="<?php echo str_replace('"', '&quot;', trim($row["nom_sede"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="fecha_preins" value="<?php echo str_replace('"', '&quot;', trim($row["fecha_preins"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
    <tr>
      <td class="dr"><input type="text" name="status" maxlength="15" value="<?php echo str_replace('"', '&quot;', trim($row["status"])) ?>"></td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
      <td class="dr">&nbsp;</td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
