Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 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 $c = new Main(); $c->Refresh(); ?>
  14.         </select>
  15.         <br>
  16.         <br>
  17.         <form method="post" action="">
  18.              <a class="inputbox">ID:</a><br> <input type="number" name="id" id="id"><br>
  19.         </form>
  20.         <a class="inputbox" name="forename">Forename:</a><br> <input type="text"><br>
  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. class Main
  33. {
  34.     public $servername = "localhost";
  35.     public $username = "admin";
  36.     public $password = "admin";
  37.     public $dbname = "aufgabe02";
  38.  
  39.     function Refresh()
  40.     {
  41.         $con = new mysqli($this->servername, $this->username, $this->password, $this->dbname);
  42.  
  43.         if(!$con)
  44.         {
  45.             die("Connection Problem: ". $con->connect_error);
  46.         }
  47.  
  48.         $sql = "SELECT * FROM aufgabe02.employee";
  49.         $result = $con->query($sql);
  50.         if(!$result)
  51.         {
  52.             die("SQL Problem: ". $con->error);
  53.         }
  54.  
  55.         if ($result->num_rows > 0)
  56.         {
  57.             while ($row = $result->fetch_assoc())
  58.             {
  59.                 $option = $row["id"] . " " . $row["forename"] . " " . $row["name"] . " " . $row["city"];
  60.                 echo "<option>" . $option . "</option>";
  61.             }
  62.         }
  63.  
  64.         $con->close();
  65.     }
  66.  
  67.     function AddUser($id, $forename, $name, $city)
  68.     {
  69.  
  70.     }
  71. }
  72.  
  73. if(isset($_POST['sent']))
  74. {
  75.    $id = $_POST["id"];
  76.    $forename = $_POST["forename"];
  77.    $name = $_POST["name"];
  78.    $city = $_POST["city"];
  79.    echo $id;
  80. }
  81.  
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement