Advertisement
Guest User

Untitled

a guest
Oct 13th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. if ((isset($_SESSION['zalogowany'])) && ($_SESSION['zalogowany']==true))
  6. {
  7. header('Location: gra.php');
  8. exit();
  9. }
  10.  
  11. ?>
  12.  
  13. <!DOCTYPE HTML>
  14. <html lang="pl">
  15. <head>
  16. <meta charset="utf-8" />
  17. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  18. <title>Osadnicy - gra przeglądarkowa</title>
  19. <style>
  20. input
  21. {
  22. height: 100px;
  23. width: 200px;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28.  
  29. <form method="post" >
  30. <input type="text" name="post">
  31. </form>
  32.  
  33.  
  34.  
  35.  
  36. <?php
  37. $servername = "localhost";
  38. $username = "root";
  39. $password = "";
  40. $dbname = "facesmash";
  41.  
  42. // Create connection
  43. $conn = new mysqli($servername, $username, $password, $dbname);
  44. // Check connection
  45. if ($conn->connect_error) {
  46. die("Connection failed: " . $conn->connect_error);
  47. }
  48.  
  49. $sql = "SELECT * FROM posty";
  50. $result = $conn->query($sql);
  51.  
  52. if ($result->num_rows > 0) {
  53. // output data of each row
  54. while($row = $result->fetch_assoc()) {
  55. echo "<br>Post: #". $row["id"]. "<br>". $row["content"]."<br>";
  56. }
  57. } else {
  58. echo "0 results";
  59. }
  60.  
  61.  
  62.  
  63. $insertData = 'insert into posty (posty) values ("'.$_POST['post'].'")';
  64.  
  65. $result = mysql_query($insertData, $conn);
  66. if($result)
  67. {
  68. echo 'Data inserted successfully';
  69. }else{
  70. echo 'Data insertion failed: ' .mysql_error();
  71. }
  72.  
  73. $conn->close();
  74. ?>
  75. </body>
  76. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement