Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Start Search Page
- <?php
- include("scripts/database_connection.php");
- include("scripts/functions.php");
- start_secure_session();
- if(is_user_logged_in($sqli_con)) {
- } else {
- header("Location: index.php");
- }
- ?>
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta charset="UTF-8" />
- <title>Source | Search</title>
- <link rel="stylesheet" type="text/css" href="style/reset.css" />
- <link rel="stylesheet" type="text/css" href="style/main.css" />
- <script>
- function search(query) {
- if(query.length > 0) {
- if(window.XMLHttpRequest) {
- xmlhttp = new XMLHttpRequest();
- } else {
- xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange = function() {
- if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
- document.getElementById("search_results").innerHTML = xmlhttp.responseText;
- }
- }
- xmlhttp.open("GET", "scripts/search.php?query=" + query, true);
- xmlhttp.send();
- } else {
- document.getElementById("search_results").innerHTML = "";
- return;
- }
- }
- </script>
- </head>
- <body>
- <?php include("scripts/includes/header.inc.php"); ?>
- <div id="site_content">
- <div id="search_bar">
- <form>
- <input type="text" name="search_query" onkeyup="search(this.value);" placeholder="Search for people..."/>
- </form>
- <div id="search_results">
- </div>
- </div>
- </div>
- <?php include("scripts/includes/footer.inc.php"); ?>
- </body>
- </html>
- #End Search Page
- #Start Search Script
- <?php
- include("database_connection.php");
- $search_query = mysqli_escape_string($sqli_con, strip_tags($_GET['query']));
- if(strlen($search_query) > 0) {
- $query = $sqli_con->query("SELECT id, username, avatar, first_name, last_name, country, gender, user_level FROM members WHERE username = '$search_query'");
- if($query->num_rows > 0) {
- $row = $query->fetch_array(MYSQLI_NUM);
- if($row[6] == 'm') {$row[6] = 'Male';} else {$row[6] = 'Female';}
- if($row[7] == 'a') {$row[7] = 'Administrator';} else if($row[7] == 'm'){$row[7] = 'Moderator';} else {$row[7] = 'Regular';}
- echo "<div id='search_result'>
- <a href='profile.php?id=". $row[0] ."'><img src='". $row[2] ."' /></a><a href='profile.php?id=". $row[0] ."'>". $row[1] ."</a>
- <br /><p>". $row[3] ." ". $row[4] ."</p><br />
- <p>". $row[5] ."</p><br />
- <p>". $row[6] ."</p><br />
- <p>". $row[7] ."</p>
- </div>";
- }
- $query->free();
- $sqli_con->close();
- }
- ?>
- #End Search Script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement