views:

367

answers:

1

Hi guys,

I have a php form, that is working. With that form I connect to a DB, where i get data out. :-) When I use the form from my Mac/laptop, i can enter the sata and I get the result.

When i try to connect with this code under here. I can pass the form, and establich connection to DB, but my query, where I put country in, is empty. So I assume that is is not sent or attched to the url.

What could be the problem?

This is the code:

// NSString *myRequestString = [[NSString alloc] initWithFormat:@"&country=Germany"];
// NSData *myRequestData = [ NSData dataWithBytes: [ myRequestString UTF8String ] length: [ myRequestString length]];
// NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [ NSURL URLWithString: @"THE URL" ]];
// [ request setHTTPMethod: @"GET" ];
// [ request setHTTPBody: myRequestData ];

The form:

<html><body>
<form action="connect.php" method="GET"> 
Country: <input name="country" type="text" /> 
<input type="submit" />
</form>
</body></html>

To finish of.. The form works, but I cannot send data from my iPhone APP :-(

Hope u can point me in the right direction.

A: 

Try setting the HTTP method to be POST instead of GET. Form submits are use POST.

In any debugging of HTTP calls, I find it really helpful to use the Charles Web debugging proxy, you can see exactly what the HTTP traffic looks like from a browser and then duplicate that request as closely as possible with your code request.

Kendall Helmstetter Gelner