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 7051915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:19:15+00:00 2026-05-28T03:19:15+00:00

I’ve never used ASIHTTPRequest before, nor have I dealt with posting anything from an

  • 0

I’ve never used ASIHTTPRequest before, nor have I dealt with posting anything from an iPhone to a web service before. I’d like to eventually save the posted variables to a database, but I am unsure if they are being posted properly at this time. When I run the following script in Xcode, I see the correct html code with inserted variables logged in the debug window. My concern is that I don’t see the same thing when I access the page in the browser. My guess is this is to be expected, but I’m not completely sure. Here is what I am doing:

string1 = [[NSString alloc] initWithString:@"Did this"];
string2 = [[NSString alloc] initWithString:@"come through?"];

NSString *urlString = @"http://www.myurl.com/post_test.php";
NSURL *url = [NSURL URLWithString: urlString];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:string1 forKey:@"String1"];
[request setPostValue:string2 forKey:@"String2"];
NSString *response = nil;
[request startSynchronous];

NSError *error = [request error];
if (!error) {
    response = [request responseString];


    NSLog(@"Response GOOD: %@", response);
}
else {
    NSLog(@"Response BAD: %@", error);
}

This prints the html code from the web page with the uploaded variables correctly, but if I go to the page in my browser the php variables are null. Here is the small php script:

<?php

    $received = array();
    $received = $_POST;
    $print_received = print_r($received, TRUE);
    echo "<pre>$print_received</pre>";
    $var1 = $received['String1'];
    $var2 = $received['String2'];
    echo "The message received was: $var1 $var2</br>";

?>

I haven’t added the mysql connection code yet because I want to make sure this posting business is successful first.

  • 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-28T03:19:16+00:00Added an answer on May 28, 2026 at 3:19 am

    If you’re getting the correct response from the code that you posted, it means your code is working. What is probably happening is that you’re not using POST when testing with your browser.

    Check to make sure $_POST[] actually contains data first. If not, presumably you’d want to output a meaningful error. It looks like you’re just building a sandbox of sorts to play and get familiar with ASIHTTPRequest, however if your goals get more complex (and your code becomes public facing) you’ll want to spend some time reading up on how to sanitize and validate POST/GET variables before using them.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a bunch of posts stored in text files formatted in yaml/textile (from
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.