0

In my iOS application (using objective-c) I send some values to my php server and write them to my mysql database tables. Until now I needed to pass at most 2 values. My post string was always like @"username=%@&password=%@". I do not have any problem with that.

However, I have to send more than 2 values now and they will be more than one. For example, I want to send something like

        array_A: [value1, value2, value3, value4],
        array_B: [value1, value2, value3, value4],
        array_C: [value1, value2, value3, value4]

How can I do that? And how can I parse it at the php side? Thanks in advance...

1
  • 1
    I would suggest trying to send the data in a json encoded format, which is very easy in php and all other languages I know (I don't know objective c though, but I'm sure you can take a look into it Commented Jan 3, 2015 at 22:20

1 Answer 1

1

It seems you used REST with GET to deliver the values, but you can also use POST. Your iOS network library should allow this or just google for AFNetwork and look for posting. If you don't like AFNetwork search for AFNetwork alternatives. You will just set the values like a dictionary and you can set multiple values for keys.

I assume your PHP script currently is retrieving the values with $_GET['username'] and the same for password. If you 'post' your values you do just the same but instead of $_GET you use $_POST['param-name'].

Alternatively to set just one key and value have a look for JSON. Please google how to create a JSON-Document of your instances and how to set it as post value. You then have to google how to parse a JSON document in PHP. This seems for me the most simplest and cleanest solution for your problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.