___ ___ erkimt Recover jQuery variable in PHP and generate cookie ______ qstntxt ___

I have this pop-up that, when clicking, will search for the geolocation of the user:

%pre%

resp_geolocalizacao.php

%pre%

There is only one way to get the city selected in the "resp_globalization.php", to generate a cookie, within the popup.

Is there any way to retrieve this variable?

    
___

0

I have this pop-up that, when clicking, will search for the geolocation of the user:

<div id="modal_success" style="display: none;">
    <div class="modalcontent">
        <div class="modal-header" style="">
            <button type="button" id="button_success" class="close">X</button>
        </div>          

        <?php
            if(isset($_POST['enviar_info']) && $_POST['enviar_info'] == 'env'){
        ?>
            <script type="text/javascript">
                jQuery(document).ready(function($){
                (function() {
                        if(!!navigator.geolocation) {
                            navigator.geolocation.getCurrentPosition(function(position) {

                            var geolocate     = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
                            var php_latitude  = position.coords.latitude;
                            var php_longitude = position.coords.longitude;

                            $.post('includes/resp_geolocalizacao.php', {'php_latitude': php_latitude, 'php_longitude': php_longitude}, function(data){});
                        });

                        } else {
                            //document.getElementById('google_canvas').innerHTML = 'No Geolocation Support.';
                        }
                    })();
                }); 
            </script>               
        <?php
            }
        ?>

        <form name="form_login" id="form_login" method="post" class="eltd-login-form_1" enctype="multipart/form-data" action="">
            <fieldset class="corpo_popup">
                Melhore sua localização
                <div class="eltd-login-button-holder" style="padding-top: 26px; text-align: center; border-top: 1px solid #e6e6e6;">
                    <button type="submit" class="eltd-btn eltd-btn-medium eltd-btn-custom-border-hover login_pop_div">   
                        <span class="eltd-btn-text">Clique aqui</span>    
                    </button>   
                    <input type="hidden" name="enviar_info" value="env" />
                </div>
            </fieldset>
        </form>                             
    </div>
</div>

resp_geolocalizacao.php

<?php

/******* Conexão com o bando de dados *******/
include "../Conexao/config.php";
mysqli_select_db($config, $database_config);
mysqli_set_charset($config,"utf8");
/******* Conexão com o bando de dados *******/  

$php_latitude   = $_POST["php_latitude"];
$php_longitude  = $_POST["php_longitude"];
$address        = $php_latitude . "," . $php_longitude;
$geocode        = file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$address.'&sensor=false');
$output         = json_decode($geocode);
$php_cidade     = $output->results[0]->address_components[2]->long_name;

//print_r($output);

$sql_1 = mysqli_query($config, "SELECT id, uf FROM tb_cidades WHERE nome = '$php_cidade'") or die(mysqli_error($config));

if(@mysqli_num_rows($sql_1) <= '0'){
    echo "";
}else{
    while($r_sql_1 = mysqli_fetch_array($sql_1)){
        $id_cidade_php = $r_sql_1[0];
        $estado_php = $r_sql_1[1];
    }
}

echo $cidade_selecionada = $php_cidade . " - " . $estado_php;

?>

There is only one way to get the city selected in the "resp_globalization.php", to generate a cookie, within the popup.

Is there any way to retrieve this variable?

    
asked by anonymous 27.05.2017 / 03:50

0 answers