Guest User

Untitled

a guest
Jan 19th, 2018
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.90 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.             <?php Refresh(); ?>
  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.     </body>
  27.  
  28. </html>
  29.  
  30. <?php
  31.  
  32.     $servername = "localhost";
  33.     $username = "user";
  34.     $password = "admin";
  35.     $dbname = "aufgabe_02";
  36.     $con = new mysqli($servername, $username, $password, $dbname);
  37.  
  38.     function Refresh()
  39.     {
  40.         global $con;
  41.         $query = "SELECT * FROM employee";
  42.  
  43.         if($con->connect_error)
  44.         {
  45.             die("Connection Problem: ". $con->connect_error);
  46.         }
  47.  
  48.         $result = $con->query($query);
  49.         while($row = $result->fetch_assoc())
  50.         {
  51.             $option = $row["id"]. " ". $row["forename"]. " ". $row["name"]. " ". $row["city"];
  52.             echo "<option>". $option ."</option>";
  53.         }
  54.  
  55.         $con->close();
  56.     }
  57.  
  58.     function AddUser($id, $forename, $name, $city)
  59.     {
  60.         global $con;
  61.  
  62.         if($con->connect_error)
  63.         {
  64.             die("Connection Problem: ". $con->connect_error);
  65.         }
  66.  
  67.         echo $forename;
  68.     }
  69.  
  70.     if(isset($_POST['sent']))
  71.     {
  72.         echo "moin";
  73.     }
  74.  
  75. ?>
Add Comment
Please, Sign In to add comment