Advertisement
Guest User

Early PHP

a guest
Aug 19th, 2014
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.86 KB | None | 0 0
  1. <?php
  2. $whereClause = "WHERE ";
  3.  
  4. $county1 = filter_input(INPUT_POST, 'county1', FILTER_SANITIZE_STRING);
  5. $county2 = filter_input(INPUT_POST, 'county2', FILTER_SANITIZE_STRING);
  6. $county3 = filter_input(INPUT_POST, 'county3', FILTER_SANITIZE_STRING);
  7. $county4 = filter_input(INPUT_POST, 'county4', FILTER_SANITIZE_STRING);
  8. $county5 = filter_input(INPUT_POST, 'county5', FILTER_SANITIZE_STRING);
  9. $county6 = filter_input(INPUT_POST, 'county6', FILTER_SANITIZE_STRING);
  10. $bhv = filter_input(INPUT_POST, 'bhv', FILTER_SANITIZE_STRING);
  11. $mrc = filter_input(INPUT_POST, 'mrc', FILTER_SANITIZE_STRING);
  12. $general = filter_input(INPUT_POST, 'general', FILTER_SANITIZE_STRING);
  13. $evv = filter_input(INPUT_POST, 'evv', FILTER_SANITIZE_STRING);
  14. $allCounties = filter_input(INPUT_POST, 'allCounties', FILTER_SANITIZE_STRING);
  15. $fillmore = filter_input(INPUT_POST, 'fillmore', FILTER_SANITIZE_STRING);
  16. $johnson = filter_input(INPUT_POST, 'johnson', FILTER_SANITIZE_STRING);
  17. $otoe = filter_input(INPUT_POST, 'otoe', FILTER_SANITIZE_STRING);
  18. $richardson = filter_input(INPUT_POST, 'richardson', FILTER_SANITIZE_STRING);
  19. $seward = filter_input(INPUT_POST, 'seward', FILTER_SANITIZE_STRING);
  20. $butler = filter_input(INPUT_POST, 'butler', FILTER_SANITIZE_STRING);
  21. $gage = filter_input(INPUT_POST, 'gage', FILTER_SANITIZE_STRING);
  22. $lancaster = filter_input(INPUT_POST, 'lancaster', FILTER_SANITIZE_STRING);
  23. $pawnee = filter_input(INPUT_POST, 'pawnee', FILTER_SANITIZE_STRING);
  24. $saline = filter_input(INPUT_POST, 'saline', FILTER_SANITIZE_STRING);
  25. $thayer = filter_input(INPUT_POST, 'thayer', FILTER_SANITIZE_STRING);
  26. $cass = filter_input(INPUT_POST, 'cass', FILTER_SANITIZE_STRING);
  27. $jefferson = filter_input(INPUT_POST, 'jefferspm', FILTER_SANITIZE_STRING);
  28. $nemaha = filter_input(INPUT_POST, 'nemaha', FILTER_SANITIZE_STRING);
  29. $polk = filter_input(INPUT_POST, 'polk', FILTER_SANITIZE_STRING);
  30. $saunders = filter_input(INPUT_POST, 'saunders', FILTER_SANITIZE_STRING);
  31. $york = filter_input(INPUT_POST, 'york', FILTER_SANITIZE_STRING);
  32. $aro = filter_input(INPUT_POST, 'aro', FILTER_SANITIZE_STRING);
  33. $clergy = filter_input(INPUT_POST, 'clergy', FILTER_SANITIZE_STRING);
  34. $intskills = filter_input(INPUT_POST, 'intskills', FILTER_SANITIZE_STRING);
  35. $bus = filter_input(INPUT_POST, 'bus', FILTER_SANITIZE_STRING);
  36. $child = filter_input(INPUT_POST, 'child', FILTER_SANITIZE_STRING);
  37. $law = filter_input(INPUT_POST, 'law', FILTER_SANITIZE_STRING);
  38. $cpr = filter_input(INPUT_POST, 'cpr', FILTER_SANITIZE_STRING);
  39. $data = filter_input(INPUT_POST, 'data', FILTER_SANITIZE_STRING);
  40. $security = filter_input(INPUT_POST, 'security', FILTER_SANITIZE_STRING);
  41. $emergency = filter_input(INPUT_POST, 'emergency', FILTER_SANITIZE_STRING);
  42. $computer = filter_input(INPUT_POST, 'computer', FILTER_SANITIZE_STRING);
  43. $mechanical = filter_input(INPUT_POST, 'mechanical', FILTER_SANITIZE_STRING);
  44. $administration = filter_input(INPUT_POST, 'administration', FILTER_SANITIZE_STRING);
  45. $firstaid = filter_input(INPUT_POST, 'firstaid', FILTER_SANITIZE_STRING);
  46. $translation = filter_input(INPUT_POST, 'translation', FILTER_SANITIZE_STRING);
  47. $construction = filter_input(INPUT_POST, 'construction', FILTER_SANITIZE_STRING);
  48. $basicclean = filter_input(INPUT_POST, 'basicclean', FILTER_SANITIZE_STRING);
  49. $foodprep = filter_input(INPUT_POST, 'foodprep', FILTER_SANITIZE_STRING);
  50. $animalcare = filter_input(INPUT_POST, 'animalcare', FILTER_SANITIZE_STRING);
  51. $heavy = filter_input(INPUT_POST, 'heavy', FILTER_SANITIZE_STRING);
  52. $license1 = filter_input(INPUT_POST, 'license1', FILTER_SANITIZE_STRING);
  53. $license2 = filter_input(INPUT_POST, 'license2', FILTER_SANITIZE_STRING);
  54. $license3 = filter_input(INPUT_POST, 'license3', FILTER_SANITIZE_STRING);
  55. $license4 = filter_input(INPUT_POST, 'license4', FILTER_SANITIZE_STRING);
  56. $license5 = filter_input(INPUT_POST, 'license5', FILTER_SANITIZE_STRING);
  57. $dist1 = filter_input(INPUT_POST, 'dist1', FILTER_SANITIZE_STRING);
  58. $dist2 = filter_input(INPUT_POST, 'dist2', FILTER_SANITIZE_STRING);
  59. $dist3 = filter_input(INPUT_POST, 'dist3', FILTER_SANITIZE_STRING);
  60. $dist4 = filter_input(INPUT_POST, 'dist4', FILTER_SANITIZE_STRING);
  61. $dist5 = filter_input(INPUT_POST, 'dist5', FILTER_SANITIZE_STRING);
  62. echo $general;
  63. if ($bhv == ""){
  64.     $bhv = "";
  65. } else
  66. {
  67.     $whereClause = $whereClause . "bhv = " . $bhv . " AND ";
  68. }
  69. if ($mrc == ""){
  70.     $mrc = "";
  71. }else
  72. {
  73.     $whereClause = $whereClause . "mrc = " . $mrc . " AND ";
  74. }
  75. if ($general == ""){
  76.     $general = "";
  77. }else
  78. {
  79.     $whereClause = $whereClause . "general = " . $general . " AND ";
  80. }
  81. if ($evv == ""){
  82.     $evv = "";
  83. }else
  84. {
  85.     $whereClause = $whereClause . "evv = " . $evv . " AND ";
  86. }
  87. if ($allCounties == ""){
  88.     $allCounties = "";
  89. }else
  90. {
  91.     $whereClause = $whereClause . "allCounties = " . $allCounties . " AND ";
  92. }
  93. if ($fillmore == ""){
  94.     $fillmore = "";
  95. }else
  96. {
  97.     $whereClause = $whereClause . "fillmore = " . $fillmore . " AND ";
  98. }
  99. if ($johnson == ""){
  100.     $johnson = "";
  101. }else
  102. {
  103.     $whereClause = $whereClause . "johnson = " . $johnson . " AND ";
  104. }
  105. if ($otoe == ""){
  106.     $otoe = "";
  107. }else
  108. {
  109.     $whereClause = $whereClause . "otoe = " . $otoe . " AND ";
  110. }
  111. if ($richardson == ""){
  112.     $richardson = "";
  113. }else
  114. {
  115.     $whereClause = $whereClause . "richardson = " . $richardson . " AND ";
  116. }
  117. if ($seward == ""){
  118.     $seward = "";
  119. }else
  120. {
  121.     $whereClause = $whereClause . "seward = " . $seward . " AND ";
  122. }
  123. if ($butler == ""){
  124.     $butler = "";
  125. }else
  126. {
  127.     $whereClause = $whereClause . "butler = " . $butler . " AND ";
  128. }
  129. if ($gage == ""){
  130.     $gage = "";
  131. }else
  132. {
  133.     $whereClause = $whereClause . "gage = " . $gage . " AND ";
  134. }
  135. if ($lancaster == ""){
  136.     $lancaster = "";
  137. }else
  138. {
  139.     $whereClause = $whereClause . "lancaster = " . $lancaster . " AND ";
  140. }
  141. if ($pawnee == ""){
  142.     $pawnee = "";
  143. }else
  144. {
  145.     $whereClause = $whereClause . "pawnee = " . $pawnee . " AND ";
  146. }
  147. if ($saline == ""){
  148.     $saline = "";
  149. }else
  150. {
  151.     $whereClause = $whereClause . "saline = " . $saline . " AND ";
  152. }
  153. if ($thayer == ""){
  154.     $thayer = "";
  155. }else
  156. {
  157.     $whereClause = $whereClause . "thayer = " . $thayer . " AND ";
  158. }
  159. if ($cass == ""){
  160.     $cass = "";
  161. }else
  162. {
  163.     $whereClause = $whereClause . "cass = " . $cass . " AND ";
  164. }
  165. if ($jefferson == ""){
  166.     $jefferson = "";
  167. }else
  168. {
  169.     $whereClause = $whereClause . "jefferson = " . $jefferson . " AND ";
  170. }
  171. if ($nemaha == ""){
  172.     $nemaha = "";
  173. }else
  174. {
  175.     $whereClause = $whereClause . "nemaha = " . $nemaha . " AND ";
  176. }
  177. if ($polk == ""){
  178.     $polk = "";
  179. }else
  180. {
  181.     $whereClause = $whereClause . "polk = " . $polk . " AND ";
  182. }
  183. if ($saunders == ""){
  184.     $saunders = "";
  185. }else
  186. {
  187.     $whereClause = $whereClause . "saunders = " . $saunders . " AND ";
  188. }
  189. if ($york == ""){
  190.     $york = "";
  191. }else
  192. {
  193.     $whereClause = $whereClause . "york = " . $york . " AND ";
  194. }
  195. if ($aro == ""){
  196.     $aro = "";
  197. }else
  198. {
  199.     $whereClause = $whereClause . "aro = " . $aro . " AND ";
  200. }
  201. if ($clergy == ""){
  202.     $clergy = "";
  203. }else
  204. {
  205.     $whereClause = $whereClause . "clergy = " . $clergy . " AND ";
  206. }
  207. if ($intskills == ""){
  208.     $intskills = "";
  209. }else
  210. {
  211.     $whereClause = $whereClause . "intskills = " . $intskills . " AND ";
  212. }
  213. if ($child == ""){
  214.     $child = "";
  215. }else
  216. {
  217.     $whereClause = $whereClause . "child = " . $child . " AND ";
  218. }
  219. if ($bus == ""){
  220.     $bus = "";
  221. }else
  222. {
  223.     $whereClause = $whereClause . "bus = " . $bus . " AND ";
  224. }
  225. if ($law == ""){
  226.     $law = "";
  227. }else
  228. {
  229.     $whereClause = $whereClause . "law = " . $law . " AND ";
  230. }
  231. if ($cpr == ""){
  232.     $cpr = "";
  233. }else
  234. {
  235.     $whereClause = $whereClause . "cpr = " . $cpr . " AND ";
  236. }
  237. if ($data == ""){
  238.     $data = "";
  239. }else
  240. {
  241.     $whereClause = $whereClause . "data = " . $data . " AND ";
  242. }
  243. if ($security == ""){
  244.     $security = "";
  245. }else
  246. {
  247.     $whereClause = $whereClause . "security = " . $security . " AND ";
  248. }
  249. if ($emergency == ""){
  250.     $emergency = "";
  251. }else
  252. {
  253.     $whereClause = $whereClause . "emergency = " . $emergency . " AND ";
  254. }
  255. if ($computer == ""){
  256.     $computer = "";
  257. }else
  258. {
  259.     $whereClause = $whereClause . "computer = " . $computer . " AND ";
  260. }
  261. if ($mechanical == ""){
  262.     $mechanical = "";
  263. }else
  264. {
  265.     $whereClause = $whereClause . "mechanical = " . $mechanical . " AND ";
  266. }
  267. if ($administration == ""){
  268.     $administration = "";
  269. }else
  270. {
  271.     $whereClause = $whereClause . "administration = " . $administration . " AND ";
  272. }
  273. if ($firstaid == ""){
  274.     $firstaid = "";
  275. }else
  276. {
  277.     $whereClause = $whereClause . "firstaid = " . $firstaid . " AND ";
  278. }
  279. if ($faid == ""){
  280.     $faid = "";
  281. }else
  282. {
  283.     $whereClause = $whereClause . "faid = " . $faid . " AND ";
  284. }
  285. if ($translation == ""){
  286.     $translation = "";
  287. }else
  288. {
  289.     $whereClause = $whereClause . "translation = " . $translation . " AND ";
  290. }
  291. if ($construction == ""){
  292.     $construction = "";
  293. }else
  294. {
  295.     $whereClause = $whereClause . "construction = " . $construction . " AND ";
  296. }
  297. if ($basicclean == ""){
  298.     $basicclean = "";
  299. }else
  300. {
  301.     $whereClause = $whereClause . "basicclean = " . $basicclean . " AND ";
  302. }
  303. if ($foodprep == ""){
  304.     $foodprep = "";
  305. }else
  306. {
  307.     $whereClause = $whereClause . "foodprep = " . $foodprep . " AND ";
  308. }
  309. if ($animalcare == ""){
  310.     $animalcare = "";
  311. }else
  312. {
  313.     $whereClause = $whereClause . "aniamalcare = " . $animalcare . " AND ";
  314. }
  315. if ($heavy == ""){
  316.     $heavy = "";
  317. }else
  318. {
  319.     $whereClause = $whereClause . "heavy = " . $heavy . " AND ";
  320. }
  321. if ($county1 == ""){
  322.     $error = "Must select at least 1 Residential County.";
  323. } elseif ($count2 == ""){
  324.     $whereClause = $whereClause . "county = " . $county1 . " AND ";
  325. } elseif ($county3 == "") {
  326.     $whereClause = $whereClause . "county = " . $county1 . " OR county = " . $county2 . " AND ";
  327. } elseif ($county4 == ""){
  328.     $whereClause = $whereClause . "county = " . $county1 . " OR county = " . $county2 . " OR county = " . $county3 . " AND ";
  329. } elseif ($county5 == ""){
  330.     $whereClause = $whereClause . "county = " . $county1 . " OR county = " . $county2 . " OR county = " . $county3 . "OR county = " . $count4 . " AND ";
  331. } elseif ($county6 == ""){
  332.     $whereClause = $whereClause . "county = " . $county1 . " OR county = " . $county2 . " OR county = " . $county3 . "OR county = " . $count4 . " OR county = " . $county5 . " AND ";
  333. } else {
  334.    $whereClause = $whereClause . "county = " . $county1 . " OR county = " . $county2 . " OR county = " . $county3 . "OR county = " . $count4 . " OR county = " . $county5 . " OR county = " . $county6 . " AND ";
  335. }
  336. if ($license1 != "" ){
  337.     $whereClause = $whereClause . "license1 = " . $license1 . " AND ";
  338. }
  339. if ($license2 != "" ){
  340.     $whereClause = $whereClause . "license2 = " . $license2 . " AND ";
  341. }
  342. if ($license3 != "" ){
  343.     $whereClause = $whereClause . "license3 = " . $license3 . " AND ";
  344. }
  345. if ($license4 != "" ){
  346.     $whereClause = $whereClause . "license4 = " . $license4 . " AND ";
  347. }
  348. if ($license5 != "" ){
  349.     $whereClause = $whereClause . "license5 = " . $license5 . " AND ";
  350. }
  351. if ($dist1 != "" ){
  352.     $whereClause = $whereClause . "dist1 = " . $dist1 . " AND ";
  353. }if ($dist2 != "" ){
  354.     $whereClause = $whereClause . "dist2 = " . $dist2 . " AND ";
  355. }if ($dist3 != "" ){
  356.     $whereClause = $whereClause . "dist3 = " . $dist3 . " AND ";
  357. }
  358. if ($dist4 != "" ){
  359.     $whereClause = $whereClause . "dist4 = " . $dist4 . " AND ";
  360. }
  361. if ($dist5 != "" ){
  362.     $whereClause = $whereClause . "dist5 = " . $dist5 . " AND ";
  363. }
  364.  
  365. $db = new PDO('mysql:host=localhost;dbname=petrzilk_test;charset=utf8', 'petrzilk_dbAdmin', 'XXXXXXXXXX'); // Connecting to Database
  366.    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Error statement
  367.    $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  368.    
  369.    $query = $db->prepare("SELECT * FROM VolunDB " . $whereClause . " 1 = 1");
  370.    $query->execute();
  371.    $result = $query->fetch(PDO::FETCH_OBJ);
  372.    $table = $result->fname . " " . $result->lname;
  373.    echo $table  ;
  374.    echo $whereClause;
  375.    echo $general;
  376.    
  377. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement