Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'base1.php';
- ?>
- <center>
- <table style="text-align:left;">
- <tr>
- <td><a href="index.php">View Guestbook</a> </td>
- <td style="width:20px;"></td>
- <td><a href="sign.php">Sign Guestbook</a> </td>
- <td style="width:20px;"></td>
- <td><a href="delete.php">Delete Guestbook</a></td>
- </tr>
- </table>
- <br />
- <?php
- if (isset($_POST['q'])) {
- $search = $_POST['q'];
- } else {
- $search = '';
- }
- if (isset($_POST['lang'])) {
- $lang = $_POST['lang'];
- } else {
- $lang = 'en';
- }
- $host="localhost"; // Host name
- $username="root"; // Mysql username
- $password=""; // Mysql password
- $db_name="webappdb"; // Database name
- $tbl_name="guestbook"; // Table name
- ?>
- <form action="/search.php" method="post">
- <center>
- <table style="text-align:left;">
- <tr>
- <td>Search for:<input type="text" name="q" value="<?php echo htmlentities($search);?>" /></td>
- <td style="width:20px;"></td>
- <td>Language:<select name="lang">
- <option value="en"<?php if ($lang == 'en'): echo ' selected="selected"'; endif;?>>EN</option>
- <option value="fr"<?php if ($lang == 'fr'): echo ' selected="selected"'; endif; ?>>FR</option>
- </select></td>
- <td style="width:20px;"></td>
- <td><input type="submit" name="" value="Search" /></td>
- </tr>
- </table>
- </center>
- <br />
- </form>
- <?php
- // Connect to server and select database.
- mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
- mysql_select_db("$db_name")or die("cannot select DB");
- $search = mysql_real_escape_string($search);
- $q = "SELECT * FROM $tbl_name WHERE comment LIKE '$search%' AND lang = '".$lang."'";
- $result=mysql_query($q) or die (mysql_error());
- echo "<table style=\"table-layout:fixed; width:700px; text-align:left; background-color:#000; border:solid #666 1px;\">
- <tr>
- <td style=\"background-color:#222; width:100px;\">ID</td>
- <td style=\"background-color:#222; width:100px;\">Name</td>
- <td style=\"background-color:#222;\">Comment</td></tr>";
- while ($rows = mysql_fetch_array($result))
- {
- ?>
- <tr><td><a href="comment.php?id=<?php echo $rows['0']; ?>"><?php echo $rows['0']; ?></a></td>
- <td ><?php echo $rows[2]; ?></td>
- <td><?php echo $rows['4']; ?></td>
- </tr>
- <?php
- }
- ?>
- <?php
- echo "</table></center><br />";
- mysql_close(); //close database
- ?>
- <br /><br /><br />
- <?php
- include 'base2.php';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement