Page 1 of 1

Need help regarding post function..

Posted: Fri Feb 11, 2011 11:07 am
by travellingsoldier
hi...i am posting my gps postion frm my mobile to this php.....

Code: Select all

<?php
    $filename = 'textfile.txt';
    // Open a file for appending
    $handle = fopen($filename, 'a+');

    // Get the data from the POST request
    $latitude = $_POST['lat'];
    $longitude = $_POST['lon'];	
    
    // PHP recommends writing the exact data length
    fwrite($handle, $latitude, strlen($latitude));
    fwrite($handle, $longitude, strlen($longitude));
    
    //Append a newline
    fwrite($handle, "\n");
    
    //close the file
    fclose($handle);    
    
?>


this script is working absolutely fine....it is writing what ever i posted from my mobile to textfile..
but i could not echo or use the variables $latitude and $longitude...........pls help

Re: Need help regarding post function..

Posted: Fri Feb 11, 2011 11:17 am
by s992
You've defined the variables $latitude and $longitude but later reference $lat and $long. Which one is it?

Re: Need help regarding post function..

Posted: Fri Feb 11, 2011 11:19 am
by travellingsoldier
actually i hav defined $lat and $lon only in the original code...i thought readers would get confused with i/p parameters and variables... so i hav changed it here

Re: Need help regarding post function..

Posted: Fri Feb 11, 2011 11:23 am
by travellingsoldier
i have edited it in the question now...pls help
i want to echo and use variables $latitude and $longitude..