Q:

Inserting data into online DB

I am trying to insert some values to MySQL DB accessing it online via iPad app.
Sends data out:
if(txtInput != nil){
        NSString *postVars = [NSString stringWithFormat:@"id=%d&input=%@", index, txtInput.text];
        NSLog(@"%d",index);
        index++;
        NSData *data = [postVars dataUsingEncoding:NSUTF8StringEncoding];

        NSString *strURL = @"http://localhost:8888/Insert.php";
        NSURL *url = [NSURL URLWithString:strURL];
        NSMutableURLRequest *req = [[NSMutableURLRequest alloc]initWithURL:url];
        [req setHTTPBody:data];
        [req setHTTPMethod:@"POST"];
        NSURLConnection *con = [NSURLConnection connectionWithRequest:req delegate:self];
    }

The script for Web service:
<?php
$host = 'localhost';
$username = 'root';
$password = 'root';

$con = mysql_connect($host, $username, $password);
if(!$con)
{
echo "Failed connection";
echo "<br/>";
die('Connection failed');
}

mysql_select_db("unbounded", $con);

$ids = $_GET['id'];
$str = $_GET['input'];

$in= mysql_query("INSERT INTO `unbounded`.`stuff` (`id`, `string`) VALUES ('$ids','$str');");
echo $in;
echo "<br/>";
mysql_close($con);
?> 

Once I run my app at PHPAdmin page I can see that id value has been set to 0 each time I execute the app whilst string value is empty.
If I run the script via browser to inserts data fine. By the way, once I execute the script vi browser I discovered that connection with DB has been established well.
.
What might be the prob?
Best regrads

A:

In your iOS app you are using POST method to send the data
[req setHTTPMethod:@"POST"];

But in the PHP you are reading from GET
$ids = $_GET['id'];

It should work if both using the same HTTP method
Not related to your question, but your PHP code is vulnerable to SQL injection attack.

