Error editing records in PHP with related tables

0

I have a small problem when updating my CRUD. To start I have three related tables:

Table User, Table location and Table Sepomex ( This last one is the one that provides emails from Mexico ) .

The user table has the foreign key of the table location and the location of the sepomex table ..

My Form I have it in the following way:

The aprte that is locked, works with Ajax, at the moment that I post the zip code automatically, doing a search to the sepomex table with the municipality and locality indexes by means of the file busqueda.php , where I make the query. This is the part of the AJAX to do the search:

    <script>
  $(document).ready(function(){
      $("#cp").keyup(function(){
          var copo = $(this).val();
          $.ajax({
              url: "busqueda.php",
              type: "POST",
              data: {cp:copo},
              dataType: 'json',
              success: function(resultado){
                  /*$.each(resultado, function(index, element) {
                      $('#mpio').val(element.muni);
                  });*/

                  $.each( resultado, function( key, value ) {
                      $.each (value, function(kk, vv) {
                          if(kk == "muni"){
                              $('#mpio').val(vv);
                          }
                          if(kk == "asentamiento"){
                              $('#loc').append("<option value='"+vv+"'>"+vv+"</option>");
                          }                    
                      })
                  });
              }
          });
      });
  });
</script>

And this is the file where I try to update my records:

<?php
    require_once("../../clase/conexion.php");

    if(
        isset($_POST["nom"]) &&
        isset($_POST["paterno"]) &&
        isset($_POST["materno"]) &&
        isset($_POST["tel"]) &&
        isset($_POST["curp"]) &&
        isset($_POST["rfc"]) &&
        isset($_POST["conrfc"]) &&
        isset($_POST["firma"]) &&
        isset($_POST["patente"]) &&
        isset($_POST["upp"]) &&

        isset($_POST["cp"]) &&
        isset($_POST["mpio"]) &&
        isset($_POST["loc"]) &&
        !empty($_POST["loc"]) &&

        isset($_POST["calle"]) &&
        isset($_POST["ext"]) &&
        isset($_POST["int"])
    ){

        $mysqli->query("
            UPDATE
                sepomex
            SET
                sepocp = ".$_POST["cp"].",
                sepomunicipio = '".$_POST["mpio"]."',
                sepoasentamiento = '".$_POST["loc"]."'
            WHERE
                sepoid = ".$_REQUEST["id_sepo"]."
        ");

        $mysqli->query("
            UPDATE
                ubicacion
            SET
                calle = '".htmlentities($_POST["calle"])."',
                num_exterior = '".htmlentities($_POST["ext"])."',
                num_interior = '".htmlentities($_POST["int"])."'
            WHERE
                id_ubicacion = ".$_REQUEST["idubicacion"]."
        ");

        $mysqli->query("
            UPDATE 
                padron
            SET
                nombre = '".htmlentities($_POST["nom"])."',
                ape_paterno = '".htmlentities($_POST["paterno"])."',
                ape_materno = '".htmlentities($_POST["materno"])."',
                telefono = '".htmlentities($_POST["tel"])."',
                curp = '".htmlentities($_POST["curp"])."',
                rfc = '".htmlentities($_POST["rfc"])."',
                contra_rfc = '".htmlentities($_POST["conrfc"])."',
                firma_elect = '".htmlentities($_POST["firma"])."',
                num_patente = ".htmlentities($_POST["patente"]).",
                clave_upp = '".htmlentities($_POST["upp"])."'

            WHERE 
                id_padron = ".$_REQUEST["id_socio"]."
        ");

        header("Location: lista_socios.php");
    }
?>

But it does not do the update correctly, I do not know what it is doing wrong ..

    
asked by Anthony 24.11.2016 в 18:13
source

0 answers