Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. <html>
  2. <title>Server logs</title>
  3. <style type="text/css">
  4. body{
  5. background-color:#fff;
  6. font-family:tahoma;
  7. }
  8. </style>
  9. <body>
  10. <center>
  11. <h3>Server updates</h3>
  12. <?php
  13. //variables for connecting.
  14. $host="localhost";
  15. $user="root";
  16. $pass="aion";
  17. $db="website";
  18. //connection to the server.
  19. $con=mysql_connect($host, $user, $pass);
  20. if($con)
  21. {
  22. echo "Connection: <font color='lime'>Connected to the database</font><br>";
  23. }
  24. else{
  25. echo "Connection: <font color='red'>Couldn't connect to the database</font><br>";
  26. }
  27. $select=mysql_select_db($db);
  28. if($select)
  29. {
  30. echo "Db status: <font color='lime'>Selected the db successfully</font>";
  31. }
  32. else{
  33. echo "Db status: <font color='red'>couldn't select the database</font>";
  34. }
  35. ?>
  36. <br><br>
  37. <form action="" method="post">
  38. <table width="300" style="text-align:center;">
  39. <tr>
  40. <td>Username: </td>
  41. <td><input type="text" name="username" placeholder="Enter your name here"></td>
  42. </tr>
  43. <tr>
  44. <td>Update: </td>
  45. <td><input type="text" name="update" placeholder="Enter update information here" style="width:300px;"></td>
  46. </tr>
  47. <tr>
  48. <td></td>
  49. <td><input type="submit" name="submit" value="Add"></td>
  50. </tr>
  51. </table>
  52. </form>
  53. <p>This was made so we can keep track of the updates we do to the server.</p>
  54. <?php
  55. if(isset($_POST['submit']))
  56. {
  57. if(!empty($_POST['username'] && !empty($_POST['update'])))
  58. {
  59. //the information that we passed from the 2 textboxes
  60. $name=$_POST['username'];
  61. $update=$_POST['update'];
  62. //variables for connecting.
  63. $host="localhost";
  64. $user="root";
  65. $pass="aion";
  66. $db="website";
  67. //connection to the server.
  68. $con=mysql_connect($host, $user, $pass);
  69. mysql_select_db($db);
  70. //running a query to insert the previous information gathered into the database.
  71. $sql=mysql_query("INSERT INTO logs (name,update) VALUES ('$name','$update') ");
  72. //running an if statement to see if the info was inserted, if it was it will display that it was inserted else display that it wasn't.
  73. if($sql)
  74. {
  75. echo "Successfully inserted the update";
  76. }
  77. else{
  78. echo "There was an error inserting the info into the database";
  79. }
  80. }
  81. else
  82. {
  83. echo "no information was entered! Please go back and input some information";
  84. }
  85. }
  86.  
  87. ?>
  88. </body>
  89. </html> `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement