Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- </head>
- <style>
- .error {color: #FF0000;}
- </style>
- <body>
- <h1>This is H1</h1>
- <?php
- $servername = "xxx";
- $username = "xxx";
- $password = xxx;
- // Create connection
- $conn = new mysqli($servername, $username, $password);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- ?>
- <?php
- $search = $searchErr = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["search"])) {
- $searchErr = "Search keyword is required";
- }
- else {
- $search = test_input($_POST["search"]);
- if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
- $nameErr = "Only letters and white space allowed";}
- }
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- ?>
- <h2>Search Keyword</h2>
- <p><span class="error">* required field.</span></p>
- <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
- Search: <input type="text" name="search" value="<?php echo $search;?>">
- <span class="error">* <?php echo $searchErr;?></span>
- <br><br>
- <input type="submit" name="submit" value="Submit"> </form>
- <?php
- echo '<h2> Search Result: </h2>';
- $searchSQL = "
- SELECT table_name FROM information_schema.tables
- WHERE LOWER(table_name) LIKE LOWER('%$search%') AND table_schema = 'xxx'";
- $result = $conn->query($searchSQL);
- echo '<form method="POST" action="show_columns.php">'; // opening form tag
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $table_name = $row['table_name'];
- echo "<input type='submit' name='table_name' value='$table_name' /> <br/>";
- }
- } else {
- echo ' ';
- }
- echo '</form>'; // closing form tag
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement