Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php session_start();
- if($_SESSION["loggedin"] == false)
- {
- header('Location: login.php');
- }
- ?>
- <html>
- <head>
- <title>
- Wyniki
- </title>
- <link rel="Stylesheet" href="css/PSIN_C9_styl.css" type="text/css" />
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- </head>
- <body>
- <?php
- echo "<nav>";
- echo "<ul>";
- echo "<li><a href=\"logout.php\">Wyloguj</a></li>";
- echo "<li><a href=\"manageaccount.php\">Konto</a><ol><li><a href=\"historia.php\">Historia operacji</a></li></ol></li>";
- echo "<li><a href=\"sessioninfo.php\">Sesja</a></li>";
- echo "<li><a href=\"index.php\">Home</a></li>";
- echo "</ul></nav>";
- $type = 'mysql';
- $host = 'localhost';
- $port = '3306';
- $username = 'root';
- $password = '';
- $database = 'nazwa_bazy'; // !!!!<--- TUTAJ ZMIEŃ NA NAZWE TWOJEJ BAZY
- $pdo = new PDO($type.':host='.$host.';dbname='.$database.';port='.$port, $username, $password );
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- if (!$link) {
- die('Something went wrong while connecting to MSSQL');
- }
- if(isset($_GET['SortBy']))
- {
- $sortuj = $_GET['SortBy'];
- }
- else
- {
- $sortuj = 0;
- }
- $zapytanie = "EXECUTE dbo.Klient_select " . $sortuj;
- $query = $pdo->query($zapytanie);
- $_SESSION["operR"] = $_SESSION["operR"] + 1;
- $query2 = $pdo->query("EXECUTE dbo.TypKlienta_select");
- $_SESSION["operR"] = $_SESSION["operR"] + 1;
- if(!mssql_num_rows($query))
- {
- echo 'Nie znaleziono wyników';
- } else {
- // The following is equal to the code below:
- //
- // while ($row = mssql_fetch_row($query)) {
- echo "<section><article>";
- echo "<table class=\"table1\">
- <thead>
- <tr>
- <th hidden><a href=\"index.php?SortBy=0\">IdKlient</a></th>
- <th><a href=\"index.php?SortBy=1\">Imię</a></th>
- <th><a href=\"index.php?SortBy=2\">Nazwisko</a></th>
- <th><a href=\"index.php?SortBy=3\">PESEL</a></th>
- <th><a href=\"index.php?SortBy=4\">Miejscowosc</a></th>
- <th><a href=\"index.php?SortBy=5\">Ulica</a></th>
- <th><a href=\"index.php?SortBy=6\">NrDomu</a></th>
- <th><a href=\"index.php?SortBy=7\">NrLokalu</a></th>
- <th><a href=\"index.php?SortBy=8\">Telefon</a></th>
- <th><a href=\"index.php?SortBy=9\">E-mail</a></th>
- <th><a href=\"index.php?SortBy=10\">Kod Pocztowy</a></th>
- <th><a href=\"index.php?SortBy=11\">Typ klienta</a></th>
- <th>Edycja</th>
- <th>Usuwanie</th>
- </tr>
- </thead>
- <tbody>";
- $row = $query->fetchAll();
- foreach($row as $item) {
- echo "<tr>";
- echo "<td hidden>" . $item["IdKlient"] . "</a></td>";
- echo "<td>" . $item["Imie"] . "</td>";
- echo "<td>" . $item["Nazwisko"] . "</td>";
- echo "<td>" . $item["PESEL"] . "</td>";
- echo "<td>" . $item["Miejscowosc"] . "</td>";
- echo "<td>" . $item["Ulica"] . "</td>";
- echo "<td>" . $item["NrDomu"] . "</td>";
- echo "<td>" . $item["NrLokalu"] . "</td>";
- echo "<td>" . $item["Telefon"] . "</td>";
- echo "<td>" . $item["Email"] . "</td>";
- echo "<td>" . $item["KodPocztowy"] . "</td>";
- $typ = $item["IdTypKlienta"];
- if($typ == 1)
- {
- echo "<td>" . "Indywidualny" . "</td>";
- }
- else if($typ == 2)
- {
- echo "<td>" . "Biznesowy" . "</td>";
- }
- echo "<td>" ."<a href=\"edytuj.php" . "?idk=" . $item["IdKlient"] . "\">Edytuj</a></td>";echo "<td>" ."<a href=\"usun.php" . "?idk=" . $item["IdKlient"] . "\">Usuń</a></td>";
- echo "</tr>";
- }
- echo "</tbody></table></article>";
- }
- echo "<article><form action=\"dodaj.php\" method=\"get\">
- <h2>Wstaw nowego użytkownika</h2>
- <fieldset>
- <legend>Parametry tabeli</legend>
- <label for=\"idk\">ID Klienta</label><input type=\"text\" name=\"idk\" id=\"idk\" required=\"required\"/><br>
- <label for=\"imie\">Imię</label><input type=\"text\" name=\"imie\" id=\"imie\" required=\"required\"/><br>
- <label for=\"nazwisko\">Nazwisko</label> <input type=\"text\" name=\"nazwisko\" id=\"nazwisko\" required=\"required\"/><br>
- <label for=\"pesel\">PESEL</label> <input type=\"text\" name=\"pesel\" id=\"pesel\" required=\"required\"/><br>
- <label for=\"miejscowosc\">Miejscowość</label> <input type=\"text\" name=\"miejscowosc\" id=\"miejscowosc\" required=\"required\"/><br>
- <label for=\"ulica\">Ulica</label> <input type=\"text\" name=\"ulica\" id=\"ulica\"/><br>
- <label for=\"nrd\">Nr Domu</label> <input type=\"text\" name=\"nrd\" id=\"nrd\" required=\"required\"/><br>
- <label for=\"nrl\">Nr lokalu</label> <input type=\"text\" name=\"nrl\" id=\"nrl\"/><br>
- <label for=\"telefon\">Telefon</label> <input type=\"text\" name=\"telefon\" id=\"telefon\" required=\"required\"/><br>
- <label for=\"email\">E-mail</label></label> <input type=\"text\" name=\"email\" id=\"email\" required=\"required\"/><br>
- <label for=\"kodpocztowy\">Kod Pocztowy</label></label> <input type=\"text\" name=\"kodpocztowy\" id=\"kodpocztowy\" required=\"required\"/><br>
- <label for=\"typklienta\">Typ klienta</label>
- <select name=\"typklienta\" id=\"typklienta\">";
- $row2 = $query2->fetchAll();
- foreach($row2 as $item2) {
- echo "<option value=\"" . $item2["IdTypKlienta"] . "\">" . $item2["NazwaTypKlienta"] . "</option>";
- }
- echo "</select>
- </fieldset>
- <input type=\"submit\" value=\"Wyślij\"><br>
- </form></section></article>";
- ?>
- </section>
- <footer>
- <?php
- echo "<a>Jesteś zalogowany jako: " . $_SESSION["imie"] . " " . $_SESSION["nazwisko"] . "</a>";
- ?>
- Copyright @ 2015 Piotr Lesiak
- </footer>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement