Advertisement
Guest User

Untitled

a guest
Jan 25th, 2017
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. <?php
  2. require_once 'users/init.php';
  3. require_once $abs_us_root.$us_url_root.'users/includes/header.php';
  4. require_once $abs_us_root.$us_url_root.'users/includes/navigation.php';
  5. ?>
  6.  
  7. <?php
  8. if(!empty($_POST)){
  9. $sql = 'SELECT * FROM users WHERE 1 = 2'; // if no interests chosen, don't return anything
  10. foreach (['small_animals', 'large_animals', 'animal_habitat', 'environment', 'habitat', 'something', 'children', 'elderly', 'disabled', 'homeless'] as $var) {
  11. $inp = Input::get($var);
  12. if ($inp == 1) {
  13. $val = str_replace('_', ' ', $var);
  14. // since your code has the values hard-coded there's no need to bind it - no security risk of injection or etc
  15. $sql .= " OR ($var = '$var')";
  16. }
  17. }
  18. // now $sql contains a full query like "SELECT * FROM users WHERE 1 = 2 OR (homeless = 'homeless') OR (environment = 'environment')
  19. $sql = "SELECT * FROM users $where";
  20. $interested_users = $db=>query($sql)=>results();
  21. }
  22. ?>
  23.  
  24. <div id="page-wrapper">
  25. <div class="container">
  26. <div class="row">
  27. <div class="col-md-12">
  28.  
  29. <form class="" action="cbsearch2.php" method="post">
  30.  
  31. <div class="form-group">
  32.  
  33. <p><strong>Type of Project</strong> <i><small>Please check the boxes that represent your project the best (you can always update them later as well).</small></i></p>
  34.  
  35. <div class="col-xs-4">
  36. <div class="checkbox">
  37. <label><input type="checkbox" name="project" class="form-check" value="1">Projects</label>
  38. </div>
  39. <div class="checkbox">
  40. <label><input type="checkbox" name="volunteer" class="form-check" value="1">Volunteers</label>
  41. </div>
  42.  
  43. <div class="checkbox">
  44. <label><input type="checkbox" name="small_animals" class="form-check" value="1">Small animals</label>
  45. </div>
  46. <div class="checkbox">
  47. <label><input type="checkbox" name="large animals" class="form-check" value="1">Large animals</label>
  48. </div>
  49. <div class="checkbox">
  50. <label><input type="checkbox" name="animal habitat"class="form-check" value="1">Animal habitat</label>
  51. </div>
  52.  
  53.  
  54.  
  55. <div class="checkbox">
  56. <label><input type="checkbox" name="environment" class="form-check" value="1">Environment</label>
  57. </div>
  58. <div class="checkbox">
  59. <label><input type="checkbox" name="habitat" class="form-check" value="1">Habitat</label>
  60. </div>
  61. <div class="checkbox">
  62. <label><input type="checkbox" name="something" class="form-check" value="1">Something</label>
  63. </div>
  64.  
  65. <div class="checkbox">
  66. <label><input type="checkbox" name="children" class="form-check" value="1">Children</label>
  67. </div>
  68. <div class="checkbox">
  69. <label><input type="checkbox" name="elderly" class="form-check" value="1">Elderly</label>
  70. </div>
  71. <div class="checkbox">
  72. <label><input type="checkbox" name="disabled" class="form-check" value="1">Disabled</label>
  73. </div>
  74.  
  75. <div class="checkbox">
  76. <label><input type="checkbox" name="homeless" class="form-check" value="1">Homeless</label>
  77. </div>
  78.  
  79. <button class="submit btn btn-custom " type="submit" name='Submit' value='submit'>Search</button>
  80. </div>
  81.  
  82. </div><!-- /.from-group -->
  83. </form>
  84. </div><!-- /.col -->
  85. </div><!-- /.row -->
  86. <hr>
  87. <div class="row">
  88. <div class="col-md-12">
  89. <?php
  90. if (!empty($_POST)) {
  91. echo "here's what we found";
  92. foreach ($interested_users as $result) {
  93. echo $result->fname.' '.$result->lname.'<br />';
  94. }
  95. }
  96. ?>
  97.  
  98. </div><!-- /.col -->
  99. </div><!-- /.row -->
  100. </div> <!-- /container -->
  101. </div> <!-- /#page-wrapper -->
  102.  
  103.  
  104. <!-- footers -->
  105. <?php require_once $abs_us_root.$us_url_root.'users/includes/page_footer.php'; // the final html footer copyright row + the external js calls ?>
  106.  
  107. <!-- Place any per-page javascript here -->
  108.  
  109.  
  110. <?php require_once $abs_us_root.$us_url_root.'users/includes/html_footer.php'; // currently just the closing /body and /html ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement