0

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.

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150
Poul John
  • 3
  • 1
  • what is the value of `@"THE URL"`? – ax. Nov 21 '09 at 14:12
  • without the host name, if you mind. – ax. Nov 21 '09 at 14:12
  • I cannot give the real address. but it looks like this: http://www.myadress.com/somthing/form.html now when i put info in the label from the form, it looks like this: http://www.myadress.com/somthing/conection.php?country=Germany – Poul John Nov 21 '09 at 14:16

1 Answers1

0

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
  • 74,769
  • 26
  • 128
  • 150