Need help regarding post function..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
travellingsoldier
Forum Newbie
Posts: 3
Joined: Fri Feb 11, 2011 10:55 am

Need help regarding post function..

Post 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
Last edited by travellingsoldier on Fri Feb 11, 2011 11:20 am, edited 1 time in total.
s992
Forum Contributor
Posts: 124
Joined: Wed Oct 27, 2010 3:06 pm

Re: Need help regarding post function..

Post by s992 »

You've defined the variables $latitude and $longitude but later reference $lat and $long. Which one is it?
travellingsoldier
Forum Newbie
Posts: 3
Joined: Fri Feb 11, 2011 10:55 am

Re: Need help regarding post function..

Post 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
travellingsoldier
Forum Newbie
Posts: 3
Joined: Fri Feb 11, 2011 10:55 am

Re: Need help regarding post function..

Post by travellingsoldier »

i have edited it in the question now...pls help
i want to echo and use variables $latitude and $longitude..
Post Reply