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

  • SEARCH
  • Home
  • 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 7892553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:53:59+00:00 2026-06-03T06:53:59+00:00

First time using POST POST information is not getting from the iPhone to the

  • 0

First time using POST

POST information is not getting from the iPhone to the PhP script. I get no errors anywhere. var_dump($_POST) shows empty. failed login returned. Any ideas where to look next or do I have a visible problem here:

     NSURL *url = [NSURL URLWithString:link];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

NSString *requestBodyString = [NSString stringWithFormat:@"txtuid=%@&txtpwd=%@", userName , password];
NSData *requestBody = [NSData dataWithBytes:[requestBodyString UTF8String]length:[requestBodyString length]];

[request setHTTPMethod:@"POST"];
[request setHTTPBody:requestBody];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"]; // added from first suggestion

connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];

After trying it six different ways, I took a modified version from a previous post.

And yet another attempt with the same results.

NSData *data = [[NSString stringWithFormat: @"txtuid=%@&txtpwd=%@", userName , password] dataUsingEncoding:NSUTF8StringEncoding];

// set up request
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:link]];
[request setHTTPMethod:@"POST"];
NSString *boundary = [NSString stringWithString:@"--------------------------------------------------"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];

// body
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: text/plain\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];  
[body appendData:[NSData dataWithData:data]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];  

[request setHTTPBody:body];
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
  • 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-06-03T06:54:01+00:00Added an answer on June 3, 2026 at 6:54 am

    See my answer here about how to use POST to upload an image. It posts to forms in a PHP file. Same concept for posting data and not uploading images, but this is a working example of how to post to a PHP script using Objective-C.

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

Sidebar

Related Questions

This is not the first time I'm using this method to send a POST
Creating a simple RPG game, first time using XNA. Trying to get my character
This is my first time using authentication library. I followed this post to install
first time using json. I currently send a postcode to a php page, and
First time using Asp.net-mvc and originally followed the NerdDinner tutorial. My form submit button
This is my first time using joomla. I don't know if I'm using the
this is my first time using StAX for parsing XML documents (still in the
I want to deploy a website the first time using Rails 3.2.1 with capistrano
I'm writing a facebook desktop application for the first time using the PyFacebook api.
I'm currently trying to access a REST API for the first time using visual

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.