Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Load MySql table from bottom to top - PHP
- <html><head></head><body>
- <form action="chat.php" method="post">
- Message: <br><textarea type="text" name="message" style="width:80%; height:300px;"></textarea><br>
- <input type="submit" />
- </form>
- <?php
- $host="****";
- $user="****";
- $password="****";
- $cxn = mysql_pconnect ($host, $user, $password);
- mysql_select_db("defaultdb", $cxn);
- if (getenv(HTTP_X_FORWARDED_FOR)) {
- $ipaddress = getenv(HTTP_X_FORWARDED_FOR);
- } else {
- $ipaddress = getenv(REMOTE_ADDR);
- }
- $message = $_POST["message"];
- mysql_query("INSERT INTO ChatTest (ID, TimeStamp, Message) VALUES ('$ipaddress', NOW(), '$message')");
- $data = mysql_query("SELECT * FROM ChatTest") or die(mysql_error());
- Print "<table border cellpadding=3>";
- Print "<tr>";
- Print "<th>ID:</th><th>TimeStamp:</th><th>Message:</th>";
- while($info = mysql_fetch_array( $data )) {
- Print "<tr>";
- Print " <td>".$info['ID'] . "</td> ";
- Print " <td>".$info['TimeStamp'] . " </td>";
- Print " <td>".$info['Message'] . "</td></tr>";
- }
- Print "</table>";
- mysql_close($cxn);
- ?>
- </body></html>
- SELECT * FROM ChatTest
- ORDER BY `TimeStamp` DESC
- 0'); DROP TABLE ChatTest --
- INSERT INTO ChatTest (ID, TimeStamp, Message)
- VALUES ('$ipaddress', NOW(), '0'); DROP TABLE ChatTest --')
- $message = mysql_real_escape_string($_POST['message']);
- $data = mysql_query("SELECT * FROM ChatTest ORDER BY PostDate DESC") or die(mysql_error());
Add Comment
Please, Sign In to add comment