Question: I save the form elements to a file and the following is working as expected.

```
$t_str .= "viewMandatory=".$_GET['viewMandatory'] ."\n";

```

But what I need is that if $\_GET is set only then it should be appended to "t\_str" string. 

If no value for viewMandatory is received from the form, it should print nothing. How to add this check to the above statement?

Answer: 
```
if (!empty($_GET['viewMandatory'])){
$t_str .= "viewMandatory=".$_GET['viewMandatory'] ."\n";
}

```

After 292 questions you should have encountered the empty() function.
```
$t_str .= (!empty($_GET['viewMandatory'])?$_GET['viewMandatory']:null;

```

This way you have less code, what makes it easier to read (at least to me, i love short forms), but the code will be executed everytime you request the page. that is not the case with Dragon's solution.

But think about code injection. Filter $\_GET['viewMandatory'] the correctway before adding it to your string! Otherwise bad code can be injected quite easy, e.g.:

```
www.yourpage.com/page.php?viewMandatory=';BAD_CODE_HERE (or " instead of ')

```