Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.87 KB | None | 0 0
  1.  
  2.  
  3. <!DOCTYPE html>
  4. <html>
  5.  
  6. <?php
  7.  
  8. $servername = "localhost";
  9. $username = "root";
  10. $password = "root";
  11. $dbname = "erlent_av31";
  12.  
  13. // Create connection
  14. $conn = new mysqli($servername, $username, $password, $dbname);
  15. // Check connection
  16. if ($conn->connect_error) {
  17.     die("Connection failed: " . $conn->connect_error);
  18. }
  19.  
  20. if(isset($_POST['SubmitButton'])){
  21.  
  22. ////////// andmed
  23. $EesNimi=$_POST['eesnimi'];
  24. $PereNimi=$_POST['perenimi'];
  25. $IsikuKood=$_POST['isikukood'];
  26. $Kursus=$_POST['kursus'];
  27.  
  28. $sql = "INSERT INTO andmed (EesNimi, PereNimi, IsikuKood, Kursus)
  29. VALUES ('$EesNimi', '$PereNimi', '$IsikuKood', '$Kursus')";
  30.  
  31.  
  32. if ($conn->query($sql) === TRUE) {
  33.     echo " ";
  34. } else {
  35.     echo "Error: " . $sql . "<br>" . $conn->error;
  36. }
  37.  
  38.  
  39.  
  40.  
  41. ////////// info
  42. $hinne=$_POST['hinne']; //tootenimi
  43. $selgitus=$_POST['selgitus']; //tootekaal
  44.  
  45. $sql = "INSERT INTO info (hinne, selgitus)
  46. VALUES ('$hinne', '$selgitus')";
  47.  
  48. if ($conn->query($sql) === TRUE) {
  49.     echo " ";
  50. } else {
  51.     echo "Error: " . $sql . "<br>" . $conn->error;
  52. }
  53.  
  54. ////////// uhenduse värk
  55. $last = $conn->insert_id;
  56. $sql = "INSERT INTO `uhendus`(andmed_id,info_id)
  57. VALUES ('$last', '$last')";
  58.  
  59.  
  60. if ($conn->query($sql) === TRUE) {
  61.     echo " ";
  62. } else {
  63.     echo "Error: " . $sql . "<br>" . $conn->error;
  64. }
  65.  
  66. }
  67.  
  68. ?>
  69.  
  70. <head>
  71.  
  72.  
  73.  
  74. </head>
  75.  
  76. <style>
  77. /* Full-width input fields */
  78. input[type=text], input[type=password], input[type=number] {
  79.     width: 100%;
  80.     padding: 12px 20px;
  81.     margin: 8px 0;
  82.     display: inline-block;
  83.     border: 1px solid #ccc;
  84.     box-sizing: border-box;
  85. }
  86.  
  87. body {
  88. background-color: ghostwhite;
  89. }
  90.  
  91. /* Set a style for all buttons */
  92. button, a {
  93.     background-color: royalblue;
  94.     color: white;
  95.     padding: 14px 20px;
  96.     margin: 8px 0;
  97.     border: none;
  98.     cursor: pointer;
  99.     width: 100%;
  100.     transition-duration: 0.4s;
  101.     font-family: Arial;
  102. }
  103.  
  104. button:hover, a:hover {
  105.     background-color: cornflowerblue;
  106.     box-shadow: 1px 1px 26px -2px rgba(0,0,0,0.75);
  107. }
  108.  
  109. /* Extra styles for the cancel button */
  110. .cancelbtn {
  111.     width: auto;
  112.     padding: 10px 18px;
  113.     background-color: #f44336;
  114. }
  115.  
  116. /* Center the image and position the close button */
  117. .imgcontainer {
  118.     text-align: center;
  119.     margin: 24px 0 12px 0;
  120.     position: relative;
  121. }
  122.  
  123. #label1, #label2, #label3, #label4, #label5 {
  124. font-family: Arial;
  125. }
  126.  
  127. img.avatar {
  128.     width: 40%;
  129.     border-radius: 50%;
  130. }
  131.  
  132. .container {
  133.     padding: 16px;
  134. }
  135.  
  136. span.psw {
  137.     float: right;
  138.     padding-top: 16px;
  139. }
  140.  
  141. /* The Modal (background) */
  142. .modal {
  143.     display: none; /* Hidden by default */
  144.     position: fixed; /* Stay in place */
  145.     z-index: 1; /* Sit on top */
  146.     left: 0;
  147.     top: 0;
  148.     width: 100%; /* Full width */
  149.     height: 100%; /* Full height */
  150.     overflow: auto; /* Enable scroll if needed */
  151.     background-color: rgb(0,0,0); /* Fallback color */
  152.     background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
  153.     padding-top: 60px;
  154. }
  155.  
  156. /* Modal Content/Box */
  157. .modal-content {
  158.     background-color: #fefefe;
  159.     margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */
  160.     border: 1px solid #888;
  161.     width: 80%; /* Could be more or less, depending on screen size */
  162. }
  163.  
  164. /* The Close Button (x) */
  165. .close {
  166.     position: absolute;
  167.     right: 25px;
  168.     top: 0;
  169.     color: #000;
  170.     font-size: 35px;
  171.     font-weight: bold;
  172. }
  173.  
  174. .close:hover,
  175. .close:focus {
  176.     color: red;
  177.     cursor: pointer;
  178. }
  179.  
  180. /* Add Zoom Animation */
  181. .animate {
  182.     -webkit-animation: animatezoom 0.6s;
  183.     animation: animatezoom 0.6s
  184. }
  185.  
  186. @-webkit-keyframes animatezoom {
  187.     from {-webkit-transform: scale(0)}
  188.     to {-webkit-transform: scale(1)}
  189. }
  190.    
  191. @keyframes animatezoom {
  192.     from {transform: scale(0)}
  193.     to {transform: scale(1)}
  194. }
  195.  
  196. /* Change styles for span and cancel button on extra small screens */
  197. @media screen and (max-width: 300px) {
  198.     span.psw {
  199.        display: block;
  200.        float: none;
  201.     }
  202.     .cancelbtn {
  203.        width: 100%;
  204.     }
  205. }
  206.  
  207. #selgitus1 {
  208.     /*Ei lähe containerist välja*/
  209.     min-width: 99.7%;
  210.     max-width: 99.7%;
  211. }
  212.  
  213. #bar01 {
  214. background-color: #eeeeee;
  215.     margin: -10px;
  216.     padding-right: 0px;
  217. }
  218.  
  219. #tabel {
  220.   font-family: verdana,arial,sans-serif;
  221.   font-size:11px;
  222.   color:#333333;
  223.   border-width: 2px;
  224.   border-color: #666666;
  225.   border-collapse: collapse;
  226. }
  227.  
  228. </style>
  229. <body>
  230.  
  231. <!--NUPUD ÜLEVAL--><!--NUPUD ÜLEVAL--><!--NUPUD ÜLEVAL-->
  232. <!--NUPUD ÜLEVAL--><!--NUPUD ÜLEVAL--><!--NUPUD ÜLEVAL-->
  233. <!--NUPUD ÜLEVAL--><!--NUPUD ÜLEVAL--><!--NUPUD ÜLEVAL-->
  234.  
  235. <div id="bar01" class="container">
  236.  
  237. <button onclick="document.getElementById('id01').style.display='block'" style="width:auto;">Andmed sisse</button>
  238.  
  239. <button onclick="document.getElementById('id02').style.display='block'" style="width:auto;">Otsi</button>
  240.  
  241. <button onclick="document.getElementById('id03').style.display='block'" style="width:auto;">Andmete tabel</button>
  242.  
  243. </div>
  244.  
  245. <!--ANDMED SISSE--><!--ANDMED SISSE--><!--ANDMED SISSE-->
  246. <!--ANDMED SISSE--><!--ANDMED SISSE--><!--ANDMED SISSE-->
  247. <!--ANDMED SISSE--><!--ANDMED SISSE--><!--ANDMED SISSE-->
  248.  
  249. <div id="id01" class="modal">
  250.  
  251.   <form class="modal-content animate" action=" " method="post">
  252.     <div class="imgcontainer">
  253.       <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span>
  254.     </div>
  255.  
  256.     <div class="container">
  257.       <label id="label1"><b>Eesnimi</b></label>
  258.       <input type="text" placeholder="Tudengi eesnimi" name="eesnimi" required>
  259.  
  260.       <label id="label2"><b>Perekonnanimi</b></label>
  261.       <input type="text" placeholder="Tudengi perekonnanimi" name="perenimi" required>
  262.  
  263.  
  264.       <label id="label3"><b>Isikukood</b></label>
  265.       <input type="number" placeholder="Tudengi isikukood" name="isikukood" required>
  266.  
  267.       <textarea rows="5" cols="50" name= "selgitus" id="selgitus1">
  268. Tunnis toimunu selgitus.
  269. </textarea>
  270.  
  271.       <label id="label4"><b>Hinne</b></label>
  272. <select  name="hinne">
  273.   <option value="5">5</option>
  274.   <option value="4">4</option>
  275.   <option
  276.  value="3">3</option>
  277.   <option value="2">2</option>
  278.   <option value="1">1</option>
  279. </select>
  280.  
  281.       <label id="label5"><b>Kursus</b></label>
  282.       <select name="kursus" required>
  283.   <option value="AV41">AV41</option>
  284.   <option value="AV31">AV31</option>
  285.   <option value="AV21">AV21</option>
  286.   <option value="AV11">AV11</option>
  287. </select>
  288.  
  289.        
  290.       <button type="submit" name="SubmitButton">Sisesta</button>
  291.     </div>
  292.  
  293.     <div class="container" style="background-color:#f1f1f1">
  294.       <!-- <button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Tagasi</button> -->
  295.     </div>
  296.   </form>
  297. </div>
  298.  
  299. <!--OTSI--><!--OTSI--><!--OTSI-->
  300. <!--OTSI--><!--OTSI--><!--OTSI-->
  301. <!--OTSI--><!--OTSI--><!--OTSI-->
  302.  
  303.  
  304. <div id="id02" class="modal">
  305.  
  306.   <form class="modal-content animate" action=" " method="post">
  307.  
  308.     <div class="imgcontainer">
  309.       <span onclick="document.getElementById('id02').style.display='none'" class="close" title="Close Modal">&times;</span>
  310.     </div>
  311.  
  312.     <div class="container">
  313.       <label id="label1"><b>Otsi tundengit tema eesnime järgi</b></label>
  314.       <input type="text" placeholder="Tudengi eesnimi" name="otsi_nimi" id="otsi_nimi">
  315.       <button type="submit" name="SearchButton" onclick="getData()" onsubmit="getData()">Otsi (nuppu uuesti vajutades kuvab kõik tulemused)</button> <!--NUPP-->
  316.       <label id="label1"><b>Andmed kuvavad peale lehekülje värskendamist</b></label>
  317.  
  318. <?php
  319.  
  320. $otsi_nimi = $_POST['otsi_nimi'];
  321.  
  322.  
  323. $sql="SELECT * FROM andmed WHERE eesnimi LIKE '$otsi_nimi%';";
  324.  
  325.  
  326. $result = $conn->query($sql);
  327.  
  328. ?>
  329.  
  330.          <table border="2" align="center" id="tabel">
  331.       <thead>
  332.         <tr>
  333.           <th>Õpilase_ID</th>
  334.           <th>Eesnimi</th>
  335.           <th>Perekonnanimi</th>
  336.           <th>Isikukood</th>
  337.           <th>Kursus</th>
  338.         </tr>
  339.       </thead>
  340.       <tbody>
  341.  
  342. <?php
  343.           while($row = $result->fetch_assoc()) {
  344.             echo
  345.             "<tr>
  346.            <td>".$row["a_ID"]."</td>
  347.            <td>".$row["eesnimi"]."</td>
  348.            <td>".$row["perenimi"]."</td>
  349.            <td>".$row["isikukood"]."</td>
  350.            <td>".$row["kursus"]."</td>
  351.            </tr>\n";
  352.           }
  353. ?>
  354.  
  355.       </tbody>
  356.  
  357.     </div>
  358.  
  359.     <div class="container" style="background-color:#f1f1f1">
  360.       <!-- <button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Tagasi</button> -->
  361.     </div>
  362.   </form>
  363. </div>
  364.  
  365.  
  366. <script>
  367.  
  368.  
  369.  
  370.  
  371. if (!is_array($error)) {
  372.  
  373. // Get the modal
  374. var modal = document.getElementById('id01');
  375.  
  376. // When the user clicks anywhere outside of the modal, close it
  377. window.onclick = function(event) {
  378.     if (event.target == modal) {
  379.         modal.style.display = "none";
  380.     }
  381. }
  382. </script>
  383.  
  384. </body>
  385. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement