javascript - php session only working locally: php, database, ajax -


i'm working on website uses google maps take browser location , uses form take 2 other fields. 4 submitted database. geolocation works fine on computers, form submission produces null results on every computer except mine. on mine, works both locally , on website. have taught myself know , totally stumped. please?

here relevant code:

index.php:

<?php header('access-control-allow-origin: *'); ?> <?php session_start(); ?>   <!doctype html> <html> <body> <form action="" method="post">         <span class="error">#<input type="text" name="id" value="<?php echo $id;?>"></span>        <span class="error">*</span>        <br><br>        <textarea name="comment" rows="5" cols="30">comment</textarea><br>        <input type="submit" name="submit" value="submit">         <span class="error"><br> must allow browser geolocation submit entry</span>     </form>      <?php       if (isset($_post['submit']))        {          $_session['number'] = $_post['id'];         $_session['comment'] = $_post['comment'];         session_write_close();       }     ?> <script type="text/javascript">       function geolocate(){         // try html5 geolocation         if(navigator.geolocation){           navigator.geolocation.getcurrentposition(function(position){             var pos = new google.maps.latlng(position.coords.latitude, position.coords.longitude);             var lat = pos.lat();             var lng = pos.lng();             ////**********************************************************************************                 $.ajax({                     type: 'get',                     url: 'scripts/submit.php',                     data: {                         lat: lat,                         lng: lng                     },                     crossdomain: true,                 datatype: 'jsonp',                     success: function( data ) {                         //console.log( data );                     }//,                     //beforesend: setheader                 });              ////**********************************************************************************           }, function() {           //end current position             handlenogeolocation(true);           });   //end function set true         }          else { //end if there's geolocation           // browser doesn't support geolocation           handlenogeolocation(false);         }   //end else       }//end geolocate        geolocate();     </script> </body> </html> 

submit.php:

<?php header('access-control-allow-origin: *'); session_start();  require("phpsql_dbinfo.php");  $id = $_session['number']; $comment =$_session['comment']; $lat = $_get[lat]; $lng = $_get[lng];  //database //open $con=mysqli_connect("localhost","$username","$password","$database");      // check connection if (mysqli_connect_errno()) {   echo "failed connect mysql: " . mysqli_connect_error(); }        //insert database     //$sql="insert markers (lat, lng, id, comment, icon) values ('$lat', '$lng', '$id', '$comment', '$icon')";  $sql="insert markers (lat, lng, number, comment) values ('$lat', '$lng', '$id', '$comment')";      // if problem query     if (!mysqli_query($con,$sql))     {          die('error: ' . mysqli_error($con));     }  //close mysqli_close($con);    ?> 

when submitted, form sets session variables, uses ajax pass latitude , longitude submit.php. retrieved in submit.php.

i can't find answer online anywhere , i'm not getting errors. in advance!


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -