Question: **My Profile php**

```
<?php
//profile.php

require_once 'includes/global.php';

//check to see if they're logged in
if(!isset($_SESSION['logged_in'])) {
    header("Location: login.php");
}

// finding user and viewing it
$tools = new FindUser();
$user = $tools->get($_REQUEST['userID']);

?>

```

This is my php for viewing user profile.

<http://mywebsite.com/profile.php?userID=5> its working fine in this way. 

i want my code to check if user is available in database for example if i add `?userID=10` which is not present in database it gives out mysql error or even if i use `http://mywebsite.com/profile.php`then also it give error. 

so now i want if user is not available in database it should give that user is not available and when we use simple `http://mywebsite.com/profile.php` it should give auto add it to `userID=1` OR REDIRECT it to home.php

If there is other way of doing this please let me know. well im very newbie in this field 

Thanks for looking my question and answering :)

**Solved**

```
<?php
//profile.php

require_once 'includes/global.php';

//check to see if they're logged in
if(!isset($_SESSION['logged_in'])) {
    header("Location: login.php");
}

$UserID = $_GET['userID'];
$CheckQuery = mysql_query("SELECT * FROM users WHERE id='$UserID'");

$CheckNumber = mysql_num_rows($CheckQuery);
if ($CheckNumber !== 1)
{
    header("Location: index.php");
}

// finding user and viewing it
$tools = new FindUser();
$user = $tools->get($_REQUEST['userID']);

?>

```

Answer: 
Yes, `find $1 -type f -name 'filename.txt' | xargs fgrep LINE_TXT`, if all you want is to locate all matches of "LINE\_TXT" in any of those files.
This is the exact use case for tools [ack](https://beyondgrep.com/), [ag](https://geoff.greer.fm/ag/) and [ripgrep](https://github.com/BurntSushi/ripgrep). Not only are they more convenient to use than `grep -r`, but, at least the latter two, are much faster too.