Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if ((isset($_SESSION['zalogowany'])) && ($_SESSION['zalogowany']==true))
- {
- header('Location: gra.php');
- exit();
- }
- ?>
- <!DOCTYPE HTML>
- <html lang="pl">
- <head>
- <meta charset="utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
- <title>Osadnicy - gra przeglądarkowa</title>
- <style>
- input
- {
- height: 100px;
- width: 200px;
- }
- </style>
- </head>
- <body>
- <form method="post" >
- <input type="text" name="post">
- </form>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "facesmash";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * FROM posty";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "<br>Post: #". $row["id"]. "<br>". $row["content"]."<br>";
- }
- } else {
- echo "0 results";
- }
- $insertData = 'insert into posty (posty) values ("'.$_POST['post'].'")';
- $result = mysql_query($insertData, $conn);
- if($result)
- {
- echo 'Data inserted successfully';
- }else{
- echo 'Data insertion failed: ' .mysql_error();
- }
- $conn->close();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement