Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6822177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:37:56+00:00 2026-05-26T21:37:56+00:00

The goal is to do a simple username/password authentication by querying a database. Until

  • 0

The goal is to do a simple username/password authentication by querying a database. Until the connection is working decently my php destination file simply has following code:

echo "Posted: " . $_POST['email'];

The code to do this synchronously is this:

NSString *post = [[NSString alloc] initWithFormat:@"email=%@&password=%@", self.email.text, ..]; // .. simplified keychainItem
NSData *postEncoded = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO];
NSString *postLength = [NSString stringWithFormat:@"%d", [postEncoded length]];

NSURL *url = [NSURL URLWithString:@"http://eng.studev.groept.be/web2.0/a11_web02/improver/app/testPost"];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postEncoded];

NSError *error = nil;
NSURLResponse *response = nil;
NSData *encodedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

NSString *data=[[NSString alloc]initWithData:encodedData encoding:NSUTF8StringEncoding];
NSLog(@"Data? %@",data);

The correct value is shown as an echo. But when trying to do this asynchronously, I get following php error: “Undefined index: email”.
I try to start the asynchronous request with this line:

[[NSURLConnection connectionWithRequest:request delegate:self] start];

Then, I have the delegate method connection:didReceiveResponse, but there I cannot seem to get the data out… Or do I need another delegate method? Also, how ‘safe’ is it to check the result of your query by using just an echo (do I need/want a stream maybe?) ??

Tia

EDIT

Problem related to the server, not to objective-C code. Asked a new question to reach the correct audience: $_POST remaining empty

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:37:57+00:00Added an answer on May 26, 2026 at 9:37 pm

    @ott is on the right track, I’ll try to clarify.

    1. You don’t need start as he says. It’s benign as the connection will start automatically.

    2. initWithRequest:delegate and connectionWithRequest:delegate: are equivalent except for the retain state of the new connection object.

    3. The real problem is b/c you are using connectionWithRequest:delegate the returned connection is autoreleased at the end of the run loop and you are not retaining it in a property. Therefore, the connection never starts.

    The solution is to add a property @property (nonatomic, retain) NSURLConnection *connection to your class and set this property to the connection returned from connection:withRequest:

    You then release the connection in the completion methods connection:didFinishLoading and connection:didFailWithError:.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the goal is simple, but rather unusual. I wrote a database auto-repair script (as
My ultimate, simple goal, is to install Wordpress. Unfortunately, Wordpress requires PHP 5.2.4 or
I am parsing a text (css) file using fscanf. The basic goal is simple;
My goal is to recognize simple gestures from accelerometers mounted on a sun spot.
My goal here is to create a very simple template language. At the moment,
My goal is to deploy a simple rails application on a windows server using
I have a fairly simple addition to the HTTP standard. An ambitious goal I
I'm making a very simple 2D RPG in Java. My goal is to do
Is there a Maven phase or goal to simply execute the main method of
Is here a way to share System.Web.Caching between IIS applications? The simple goal is:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.