Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.22 KB | None | 0 0
  1. <!Doctype HTML>
  2. <html>
  3.  
  4.     <head>
  5.         <title>Aufgabe 2</title>
  6.         <meta charset="UTF-8">
  7.         <link rel="stylesheet" type="text/css" href="index.css">
  8.     </head>
  9.  
  10.     <body>
  11.         <h1 style="text-decoration: underline">Mitarbeiter</h1>
  12.         <select name="list" size="15%" style="width: 40%;">
  13.  
  14.         </select>
  15.         <br>
  16.         <br>
  17.         <a class="inputbox" name="id">ID:</a><br> <input type="number"><br>
  18.         <form method="post" action="">
  19.         <a class="inputbox" name="forename">Forename:</a><br> <input type="text"><br>
  20.         </form>
  21.         <a class="inputbox" name="name">Name:</a><br> <input type="text"><br>
  22.         <a class="inputbox" name="city">City:</a><br> <input type="text"><br><br>
  23.         <form method="post" action="">
  24.             <button type="submit" name="sent">Hinzufügen</button>
  25.         </form>
  26.         <?php Refresh(); ?>
  27.     </body>
  28.  
  29. </html>
  30.  
  31. <?php
  32.  
  33.     $servername = "localhost";
  34.     $username = "admin";
  35.     $password = "admin";
  36.     $dbname = "aufgabe02";
  37.  
  38.     function Refresh()
  39.     {
  40.         global $servername;
  41.         global $username;
  42.         global $password;
  43.         global $dbname;
  44.         $con = new mysqli($servername, $username, $password, $dbname);
  45.  
  46.         if(!$con)
  47.         {
  48.             die("Connection Problem: ". $con->connect_error);
  49.         }
  50.  
  51.         $sql = "SELECT * FROM aufgabe02.employee";
  52.         $result = $con->query($sql);
  53.         if(!$result)
  54.         {
  55.             echo "Error: ". $con->error;
  56.         }
  57.         if ($result->num_rows > 0)
  58.         {
  59.             while ($row = $result->fetch_assoc())
  60.             {
  61.                 $option = $row["id"] . " " . $row["forename"] . " " . $row["name"] . " " . $row["city"];
  62.                 echo "<option>" . $option . "</option>";
  63.             }
  64.         }
  65.         else{
  66.             echo "<option>LEER</option>";
  67.         }
  68.  
  69.         $con->close();
  70.     }
  71.  
  72.     function AddUser($id, $forename, $name, $city)
  73.     {
  74.         global $con;
  75.  
  76.         if($con->connect_error)
  77.         {
  78.             die("Connection Problem: ". $con->connect_error);
  79.         }
  80.  
  81.         echo $forename;
  82.     }
  83.  
  84.     if(isset($_POST['sent']))
  85.     {
  86.         echo "moin";
  87.     }
  88.  
  89. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement