Page 1 of 1

post from iphone to php

Posted: Tue Feb 23, 2010 2:13 pm
by quique
im posting from iphone to php server file that will write to mySQL db. Ive got the post in %20 format and it looks like this:

status:tagid=F6869FB4,latitude=37.331689,longitude=-122.030731

but im not sure how to post it. Ive got the manual user input form.html laid out and the corresponding write.php file. But the values are not getting posting, how should i encode them or format them for the write.php file to receive them?

Re: post from iphone to php

Posted: Tue Feb 23, 2010 2:22 pm
by s.dot
You can use the header() function to post data.

Code: Select all

$req = "yourdatahere";
header("POST /yourscript.php HTTP/1.0");
header("Host: http://www.yourdomain.com");
header("Content-Type: application/x-www-form-urlencoded");
header("Content-Length: " . strlen($req));
header($req);

Re: post from iphone to php

Posted: Tue Feb 23, 2010 3:43 pm
by quique
scottayy wrote:You can use the header() function to post data.

Code: Select all

$req = "yourdatahere";
header("POST /yourscript.php HTTP/1.0");
header("Host: http://www.yourdomain.com");
header("Content-Type: application/x-www-form-urlencoded");
header("Content-Length: " . strlen($req));
header($req);

Hmm...No sure what you mean. Im sending info from the iphone to the php file that writes to mySQL...