Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php parameters transfer

Tags:

post

php

sdk

I try to send some text from my app to php, but somehow I never receive text. What 's wrong here?

NSString *name = [[NSString alloc]initWithString: @"Hello World"];
NSString *email = [[NSString alloc]initWithString: @"Ohai2u"];
NSString *urlString = [NSString stringWithFormat:@"http://www.myhosturlxyz.com/tracktxt.php?name=%@ email=%@",
                       [name stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
                       [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

NSURL *url = [[NSURL alloc] initWithString:urlString];

NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];

NSData *urlData;
NSURLResponse *response;
urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:nil];
[url release];

The php I made is

<?php
    $name = $_REQUEST['name'];
    $email = $_REQUEST['email'];
    $myFile = "tracktxtf.txt";
    $fh = fopen($myFile, 'a') or die("can't open file");
    fwrite($fh, "my posted var is " .$name $email "\n");
    fclose($fh);   
 ?>
like image 510
am bakker Avatar asked Jun 14 '26 13:06

am bakker


1 Answers

Just a wild guess, but might you need & between name=%@ and email=%a, making it name=%@&email=%@?

Or, can you try using $_GET['name'] and $_GET['email'] instead of REQUEST? Perhaps try writing print_r($_REQUEST, true); print_r($_GET, true); to your debug file and see what it contains.

like image 200
Tim S Avatar answered Jun 16 '26 04:06

Tim S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!