if (!isset($_SESSION)) {
    session_start();
    //sec_session_start();
}
if (login_check($mysqli) == true) {
    $logged_in = true;
    //load user permissions and data
    include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/user_profile.php';
    include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/user_articles.php';
} else {
    $logged_in = false;
}
//search query (remove from this page i nto a php file in includes!!)
//$query = "SELECT * FROM users INNER JOIN user_information on users.id = user_information.user_id WHERE id = ?";
//'$_POST['search_general']
$users = get_search_users($_GET['search_general'], $mysqli);
?>

<!DOCTYPE html>
<html>
    <head>
      <title>Search Results</title>
                  
      <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      
      <link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
      <link rel="stylesheet" href="/css/login.css"/> 
      <link rel="stylesheet" type="text/css" href="/css/Crabtown v1.0.css">    
      <link rel="stylesheet" href="/css/login_menu.css"/>  
            $page = intval($_GET['page']) - 1;
            if ($page < 0) {
                $page = 0;
            }
        } elseif (isset($_GET['next'])) {
            $page = intval($_GET['page']) + 1;
        } else {
            $page = 0;
        }
    }
} else {
    $query = '';
    $page = 0;
}
require 'page_top.html';
print '<h2>Search Users</h2>';
// Display the form with empty fields
// or the values entered when a button was clicked
print "<form action='search_users.php' method='get'>";
print "Search Terms: <input type='text' name='query' value='{$query}' size='50'>";
print "<input type='hidden' name='page' value={$page}>";
print '<button type="submit" name="submit" value=1>Search</button>';
print '<button type="submit" name="prev" value=1>< Prev</button>';
print '<button type="submit" name="next" value=1>Next ></button>';
print '</form>';
if (!empty($where)) {
    require '../get_search_users.php';
    $users = get_search_users($where, $page * $results_per_page, $results_per_page);
    require 'display_users.php';
}
require 'page_bottom.html';