SHARE
TWEET

aaa kontroll aaaaaa

a guest May 22nd, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.   session_start();
  3.   if(!isset($_SESSION["benutzername"])){
  4.     header("Location: login.php");
  5.   }
  6.  
  7.   $out3 = "";
  8.  
  9.   if(isset($_POST["posten"])) {
  10.  
  11.     $server = "localhost";
  12.     $usr = "root";
  13.     $passwd = "root";
  14.     $datab = "nera";
  15.  
  16.     $conn2 = mysqli_connect($server, $usr, $passwd, $datab);
  17.  
  18.     if(!$conn2){
  19.       die("Connection 2 failed:" .mysqli_connect_error());
  20.     }
  21.  
  22.     $post = $_POST["status"];
  23.     $benutzer = $_SESSION["benutzername"];
  24.     $sql2 = "INSERT INTO post (FIBenutzer, Post) VALUES ('$benutzer','$post')";
  25.  
  26.     $result2 = mysqli_query($conn2, $sql2);
  27.  
  28.     if(!$result2){
  29.       die("Die Abfrage konnte nicht ausgeführt werden:" . mysqli_error($conn2));
  30.     }
  31.  
  32.     mysqli_close($conn2);
  33.   }
  34.  
  35.  
  36.     $servername = "localhost";
  37.     $user = "root";
  38.     $password = "root";
  39.     $database = "nera";
  40.  
  41.     $conn = mysqli_connect($servername, $user, $password, $database) or die("Connection failed:" .mysqli_connect_error());
  42.  
  43.     $sql = "SELECT IDPost, FIBenutzer, Post FROM post WHERE FIBenutzer = '{$_SESSION["benutzername"]}'";
  44.  
  45.     $result = mysqli_query($conn, $sql) or die("Failure" .mysqli_error($conn));
  46.  
  47.     $benutzer = $_SESSION["benutzername"];
  48.  
  49.       $out3 = "<table border='1'>";
  50.       $out3 .= "<th>Benutzer</th><th>Posts</th>";
  51.       while($row = mysqli_fetch_assoc($result)) {
  52.         $out3 .= "<tr><td>$benutzer</td><td>{$row["Post"]}</td></tr>";
  53.       }
  54.       $out3 .= "</table>";
  55.  
  56.  
  57.     mysqli_close($conn);
  58.  
  59.  
  60. ?>
  61. <!DOCTYPE html>
  62. <html>
  63.   <head>
  64.     <meta charset="utf-8">
  65.     <title>Startseite</title>
  66.     <link rel="stylesheet" type="text/css" href="style.css">
  67.   </head>
  68.   <body>
  69.     <h1>NERA</h1>
  70.     <div class="menu">
  71.       <a href="logoff.php"><h4>Abmelden</h4></a>
  72.       <a href="profil.php"><h4>Profil</h4></a>
  73.     </div>
  74.  
  75.     <div class="bild">
  76.       <?php if(!isset($profilbild)){
  77.         echo "<a href='profil.php'><img src='nkb.jpg' id='bild'></a>";
  78.       } ?>
  79.     </div>
  80.  
  81.  
  82.     <div class="index">
  83.       <form method="post">
  84.         <input type="textarea" name="status" autofocus placeholder="Poste etwas..">
  85.     </div>
  86.         <input type="submit" name="posten" value="Posten">
  87.       </form>
  88.       <p><h2>Posts</h2></p>
  89.       <?php echo $out3; ?>
  90.   </body>
  91.  
  92. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top