Advertisement
Guest User

Untitled

a guest
May 31st, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. <?php
  2. mysql_connect("localhost","root");
  3. mysql_select_db("testdb");
  4. ?>
  5. <style>
  6. a {
  7. text-decoration: none;
  8. }
  9. ul {
  10. text-align: center;
  11. overflow: auto;
  12. width: 100%;
  13. }
  14. li {
  15. float: left;
  16. width: 31%;
  17. background-color: transparent;
  18. border: 1px white solid;
  19. display: inline;
  20. font-size: 200%;
  21. padding: 10px;
  22. list-style-type: none;
  23. }
  24. input, textarea, button, select, option {
  25. float: left;
  26. margin-top: 20px;
  27. background-color: transparent;
  28. color: white;
  29. font-size: 150%;
  30. width: 96.5%;
  31. border: 1px white solid;
  32. outline: none;
  33. }
  34. option {
  35. background-color: #104378;
  36. }
  37. input[type="submit"], button{
  38. width: 100px;
  39. padding: 10px;
  40. }
  41. </style>
  42. <script>
  43. $(function() {
  44. $( "#tabs" ).tabs();
  45. });
  46. $(document).ready(function(){
  47. $("button#eins").click(function(){
  48. $("div#table").html($("div#table").html()+"<input type='text' name='arrayname[]'>");
  49. });
  50. $("button#zwei").click(function(){
  51. if($("div#table input:last-child").val() == "ID"){
  52.  
  53. } else {
  54. $("div#table input:last-child").remove();
  55. }
  56. });
  57. $('select').on('change', function(){
  58. $.get("reader.php?type=getColumns&tabelle="+$(this).val(), function(data){
  59. $("div#selectGoto").html(data);
  60. });
  61. });
  62. });
  63. </script>
  64. <div id="tabs">
  65. <ul>
  66. <li><a href="#tabs-1">&Uuml;bersicht</a></li>
  67. <li><a href="#tabs-2">Projekt Erstellen</a></li>
  68. <li><a href="#tabs-3">Datensatz zu Projekt Erstellen</a></li>
  69. <div id="tabs-1">
  70. </div>
  71. <div id="tabs-2">
  72. <form action="add.php" method="post">
  73. <input type="text" name="projektName" placeholder="Projekt Name" autocomplete="off">
  74. <input type="text" name="projektbezeichnung" placeholder="Projekt Name (nur a-z,A-Z,0-9)" autocomplete="off">
  75. <textarea name="anmerkung" placeholder="Anmerkung..."></textarea>
  76. <div id="table">
  77. <input type="text" name="table" value="ID" disabled="true">
  78. </div>
  79. <input type="submit" name="submit_projekt">
  80. </form><button id="eins">+</button><button id="zwei">-</button>
  81. </div>
  82. <div id="tabs-3">
  83. <form action="add.php" method="post">
  84. <select>
  85. <?php
  86. $result = mysql_query("show tables");
  87. echo "<option>W&auml;hle ein Projekt aus</option>";
  88. while($table = mysql_fetch_array($result)) {
  89. echo "<option>".$table[0]."</option>";
  90. }
  91. ?>
  92. </select>
  93. <div id="selectGoto"></div>
  94. <input type="submit" name="submit_entry">
  95. </form>
  96. </div>
  97. </div>
  98.  
  99. <div id="fenster"></div>
  100. <?php
  101.  
  102. if(isset($_POST['submit_projekt'])){
  103. $projektName = $_POST['projektName'];
  104. $projektbezeichnung = $_POST['projektbezeichnung'];
  105. $projektAnmerkung = $_POST['anmerkung'];
  106. $datum = date("d.m.Y");
  107. $zeit = date("H:i:s");
  108. $ip = $_SERVER['REMOTE_ADDR'];
  109.  
  110. $checkAvail = mysql_query("SELECT * FROM projekte where projekt like '$projektName'");
  111. if(mysql_num_rows($checkAvail) == 0){
  112. if(strlen($projektName) > 3){
  113. mysql_query("INSERT INTO projekte (projekt, bezeichnung, datum,zeit,ip,anmerkung) VALUES ('$projektName','$projektbezeichnung','$datum','$zeit','$ip','$projektAnmerkung')");
  114. mysql_query("CREATE TABLE `$projektbezeichnung` (`id` int(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
  115. mysql_query("ALTER TABLE `$projektbezeichnung` ADD PRIMARY KEY (`id`);");
  116. mysql_query("ALTER TABLE `$projektbezeichnung` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;");
  117.  
  118.  
  119. $array = $_POST['arrayname'];
  120. $count = count($array);
  121. $i = 0;
  122. while($i < $count){
  123. $reihe = $array[$i];
  124. mysql_query("ALTER TABLE `$projektbezeichnung` ADD `$reihe` TEXT NOT NULL FIRST;");
  125. $i++;
  126. }
  127. }
  128. }
  129. Header('location: index.php');
  130. }
  131.  
  132. if(isset($_POST['submit_entry'])){
  133. $allfields = $_POST['allFields'];
  134. $tableName = $_POST['tableName'];
  135. $explode = explode(",",$allfields);
  136. $count = count($explode);
  137. $i = 0;
  138. $sql = "(";
  139. while($i < $count){
  140. $sql = $sql.$explode[$i].",";
  141. $i++;
  142. }
  143. $sql = substr_replace($sql, "", -2);
  144. $sql = $sql.") VALUES (";
  145. $ii = 0;
  146. while($ii < $count){
  147. $explode = explode(",",$allfields);
  148. $var = $explode[$ii];
  149. $var2 = $_POST[$var];
  150. //array_search($ii, $_POST);
  151. $sql = $sql."'".$var2."'";
  152. $ii++;
  153. }
  154. $sql = $sql.")";
  155. echo $sql;
  156. mysql_query("INSERT INTO `$tableName` $sql");
  157. }
  158. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement