Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.75 KB | None | 0 0
  1. <?php session_start();
  2.  
  3. if($_SESSION["loggedin"] == false)
  4. {
  5. header('Location: login.php');
  6. }
  7. ?>
  8. <html>
  9. <head>
  10. <title>
  11. Wyniki
  12. </title>
  13. <link rel="Stylesheet" href="css/PSIN_C9_styl.css" type="text/css" />
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15.  
  16. </head>
  17. <body>
  18.  
  19. <?php
  20. echo "<nav>";
  21. echo "<ul>";
  22. echo "<li><a href=\"logout.php\">Wyloguj</a></li>";
  23. echo "<li><a href=\"manageaccount.php\">Konto</a><ol><li><a href=\"historia.php\">Historia operacji</a></li></ol></li>";
  24. echo "<li><a href=\"sessioninfo.php\">Sesja</a></li>";
  25. echo "<li><a href=\"index.php\">Home</a></li>";
  26. echo "</ul></nav>";
  27.  
  28. $type = 'mysql';
  29. $host = 'localhost';
  30. $port = '3306';
  31. $username = 'root';
  32. $password = '';
  33. $database = 'nazwa_bazy'; // !!!!<--- TUTAJ ZMIEŃ NA NAZWE TWOJEJ BAZY
  34.  
  35. $pdo = new PDO($type.':host='.$host.';dbname='.$database.';port='.$port, $username, $password );
  36. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  37.  
  38.  
  39. if (!$link) {
  40. die('Something went wrong while connecting to MSSQL');
  41. }
  42.  
  43. if(isset($_GET['SortBy']))
  44. {
  45.  
  46. $sortuj = $_GET['SortBy'];
  47. }
  48. else
  49. {
  50. $sortuj = 0;
  51. }
  52. $zapytanie = "EXECUTE dbo.Klient_select " . $sortuj;
  53. $query = $pdo->query($zapytanie);
  54. $_SESSION["operR"] = $_SESSION["operR"] + 1;
  55. $query2 = $pdo->query("EXECUTE dbo.TypKlienta_select");
  56. $_SESSION["operR"] = $_SESSION["operR"] + 1;
  57.  
  58. if(!mssql_num_rows($query))
  59. {
  60. echo 'Nie znaleziono wyników';
  61. } else {
  62. // The following is equal to the code below:
  63. //
  64. // while ($row = mssql_fetch_row($query)) {
  65.  
  66. echo "<section><article>";
  67.  
  68. echo "<table class=\"table1\">
  69. <thead>
  70. <tr>
  71. <th hidden><a href=\"index.php?SortBy=0\">IdKlient</a></th>
  72. <th><a href=\"index.php?SortBy=1\">Imię</a></th>
  73. <th><a href=\"index.php?SortBy=2\">Nazwisko</a></th>
  74. <th><a href=\"index.php?SortBy=3\">PESEL</a></th>
  75. <th><a href=\"index.php?SortBy=4\">Miejscowosc</a></th>
  76. <th><a href=\"index.php?SortBy=5\">Ulica</a></th>
  77. <th><a href=\"index.php?SortBy=6\">NrDomu</a></th>
  78. <th><a href=\"index.php?SortBy=7\">NrLokalu</a></th>
  79. <th><a href=\"index.php?SortBy=8\">Telefon</a></th>
  80. <th><a href=\"index.php?SortBy=9\">E-mail</a></th>
  81. <th><a href=\"index.php?SortBy=10\">Kod Pocztowy</a></th>
  82. <th><a href=\"index.php?SortBy=11\">Typ klienta</a></th>
  83. <th>Edycja</th>
  84. <th>Usuwanie</th>
  85. </tr>
  86. </thead>
  87. <tbody>";
  88. $row = $query->fetchAll();
  89. foreach($row as $item) {
  90. echo "<tr>";
  91. echo "<td hidden>" . $item["IdKlient"] . "</a></td>";
  92. echo "<td>" . $item["Imie"] . "</td>";
  93. echo "<td>" . $item["Nazwisko"] . "</td>";
  94. echo "<td>" . $item["PESEL"] . "</td>";
  95. echo "<td>" . $item["Miejscowosc"] . "</td>";
  96. echo "<td>" . $item["Ulica"] . "</td>";
  97. echo "<td>" . $item["NrDomu"] . "</td>";
  98. echo "<td>" . $item["NrLokalu"] . "</td>";
  99. echo "<td>" . $item["Telefon"] . "</td>";
  100. echo "<td>" . $item["Email"] . "</td>";
  101. echo "<td>" . $item["KodPocztowy"] . "</td>";
  102. $typ = $item["IdTypKlienta"];
  103. if($typ == 1)
  104. {
  105. echo "<td>" . "Indywidualny" . "</td>";
  106. }
  107. else if($typ == 2)
  108. {
  109. echo "<td>" . "Biznesowy" . "</td>";
  110. }
  111. echo "<td>" ."<a href=\"edytuj.php" . "?idk=" . $item["IdKlient"] . "\">Edytuj</a></td>";echo "<td>" ."<a href=\"usun.php" . "?idk=" . $item["IdKlient"] . "\">Usuń</a></td>";
  112. echo "</tr>";
  113.  
  114. }
  115.  
  116. echo "</tbody></table></article>";
  117.  
  118. }
  119.  
  120. echo "<article><form action=\"dodaj.php\" method=\"get\">
  121.  
  122. <h2>Wstaw nowego użytkownika</h2>
  123. <fieldset>
  124.  
  125. <legend>Parametry tabeli</legend>
  126. <label for=\"idk\">ID Klienta</label><input type=\"text\" name=\"idk\" id=\"idk\" required=\"required\"/><br>
  127. <label for=\"imie\">Imię</label><input type=\"text\" name=\"imie\" id=\"imie\" required=\"required\"/><br>
  128. <label for=\"nazwisko\">Nazwisko</label> <input type=\"text\" name=\"nazwisko\" id=\"nazwisko\" required=\"required\"/><br>
  129. <label for=\"pesel\">PESEL</label> <input type=\"text\" name=\"pesel\" id=\"pesel\" required=\"required\"/><br>
  130. <label for=\"miejscowosc\">Miejscowość</label> <input type=\"text\" name=\"miejscowosc\" id=\"miejscowosc\" required=\"required\"/><br>
  131. <label for=\"ulica\">Ulica</label> <input type=\"text\" name=\"ulica\" id=\"ulica\"/><br>
  132. <label for=\"nrd\">Nr Domu</label> <input type=\"text\" name=\"nrd\" id=\"nrd\" required=\"required\"/><br>
  133. <label for=\"nrl\">Nr lokalu</label> <input type=\"text\" name=\"nrl\" id=\"nrl\"/><br>
  134. <label for=\"telefon\">Telefon</label> <input type=\"text\" name=\"telefon\" id=\"telefon\" required=\"required\"/><br>
  135. <label for=\"email\">E-mail</label></label> <input type=\"text\" name=\"email\" id=\"email\" required=\"required\"/><br>
  136. <label for=\"kodpocztowy\">Kod Pocztowy</label></label> <input type=\"text\" name=\"kodpocztowy\" id=\"kodpocztowy\" required=\"required\"/><br>
  137. <label for=\"typklienta\">Typ klienta</label>
  138. <select name=\"typklienta\" id=\"typklienta\">";
  139. $row2 = $query2->fetchAll();
  140. foreach($row2 as $item2) {
  141. echo "<option value=\"" . $item2["IdTypKlienta"] . "\">" . $item2["NazwaTypKlienta"] . "</option>";
  142. }
  143. echo "</select>
  144.  
  145.  
  146. </fieldset>
  147. <input type=\"submit\" value=\"Wyślij\"><br>
  148.  
  149. </form></section></article>";
  150.  
  151. ?>
  152. </section>
  153. <footer>
  154. <?php
  155. echo "<a>Jesteś zalogowany jako: " . $_SESSION["imie"] . " " . $_SESSION["nazwisko"] . "</a>";
  156. ?>
  157. Copyright @ 2015 Piotr Lesiak
  158. </footer>
  159. </body>
  160. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement