Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php print( '<?xml version = "1.0" encoding = "utf-8"?>' ) ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <!-- Fig. 19.15: database.php -->
- <!-- Querying a database and displaying the results. -->
- <html xmlns = "http://www.w3.org/1999/xhtml">
- <head>
- <title>Search Results</title>
- <style type = "text/css">
- body { font-family: arial, sans-serif;
- background-color: #F0E68C }
- table { background-color: #ADD8E6 }
- td { padding-top: 4px;
- padding-bottom: 4px;
- padding-left: 8px;
- padding-right: 8px;
- border-width: 2px;
- border-style: inset }
- </style>
- </head>
- <body>
- <?php
- $servername = 'mysql.cba.pl';
- $username = 'zangetsudim';
- $password = '1Dead2Daylight1';
- $dbname = 'zangetsudim';
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error){
- die("connection failed : " . $conn->connection_error);
- }
- $query = $_GET['query'];
- $query = htmlspecialchars($query);
- $query = mysql_real_escape_string($query);
- $sql = mysql_query("SELECT * FROM User
- WHERE ('%".$select."%'` LIKE '%".$query."%') or die(mysql_error());
- if(mysql_num_rows($sql) > 0)){
- echo "<table><tr><th>ID</th><th>username</th><th>Country</th><th>IP</th><th>Mac</th></tr>";
- while($row = mysql_fetch_array($sql))
- echo "<tr><td>".$row["id"]."</td><td>".$row["username"]." <td>" .$row["Country"]."</td><td>".$row["IP"]."</td><td>".$row["Mac"]."</td></tr>";
- }
- }
- echo "</table>";
- }
- else{
- echo "0 results";
- }
- $conn->close();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement