Question: Before anything pops up in your mind, please understand that I am very new to PHP and to be honest, I am depending exclusively on stack overflow to build my simple and first php web application. 

I am trying to get the data from a query string and store it in my database. I want someone to write a short piece of code to check whether the string exists and if it does, add it to my database. I am using wordprss so i think we can use $\_GET and $wpdb but i don't know the syntax. The url with querystring is something like:
<http://www.mydomain.tld/?publishid=1235ABC>

Answer: 
According to given address <http://www.mydomain.tld/?publishid=1235ABC> it would be something like below::

```
    <?php
       $input = isset($_GET['publishid']) ? $_GET['publishid'] : '';
       if(!empty($input)) {
          $query = "INSERT INTO table (input_field) VALUES ('$input')";
          mysql_query($query);
       }
    ?>

```
love the answers from ([bariz](https://stackoverflow.com/a/5610650/2891692) and [Nobita](https://stackoverflow.com/a/5610624/2891692)) and love this little modification

```php
        <?php
           if(!empty($_GET['publishid'])) {
              $input = $_GET['publishid'];
              $query = "INSERT INTO table (input_field) VALUES ('$input')";
              mysql_query($query);
           }
        ?>

```