Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'users/init.php';
- require_once $abs_us_root.$us_url_root.'users/includes/header.php';
- require_once $abs_us_root.$us_url_root.'users/includes/navigation.php';
- ?>
- <?php
- if(!empty($_POST)){
- $sql = 'SELECT * FROM users WHERE 1 = 2'; // if no interests chosen, don't return anything
- foreach (['small_animals', 'large_animals', 'animal_habitat', 'environment', 'habitat', 'something', 'children', 'elderly', 'disabled', 'homeless'] as $var) {
- $inp = Input::get($var);
- if ($inp == 1) {
- $val = str_replace('_', ' ', $var);
- // since your code has the values hard-coded there's no need to bind it - no security risk of injection or etc
- $sql .= " OR ($var = '$var')";
- }
- }
- // now $sql contains a full query like "SELECT * FROM users WHERE 1 = 2 OR (homeless = 'homeless') OR (environment = 'environment')
- $sql = "SELECT * FROM users $where";
- $interested_users = $db=>query($sql)=>results();
- }
- ?>
- <div id="page-wrapper">
- <div class="container">
- <div class="row">
- <div class="col-md-12">
- <form class="" action="cbsearch2.php" method="post">
- <div class="form-group">
- <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>
- <div class="col-xs-4">
- <div class="checkbox">
- <label><input type="checkbox" name="project" class="form-check" value="1">Projects</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="volunteer" class="form-check" value="1">Volunteers</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="small_animals" class="form-check" value="1">Small animals</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="large animals" class="form-check" value="1">Large animals</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="animal habitat"class="form-check" value="1">Animal habitat</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="environment" class="form-check" value="1">Environment</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="habitat" class="form-check" value="1">Habitat</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="something" class="form-check" value="1">Something</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="children" class="form-check" value="1">Children</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="elderly" class="form-check" value="1">Elderly</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="disabled" class="form-check" value="1">Disabled</label>
- </div>
- <div class="checkbox">
- <label><input type="checkbox" name="homeless" class="form-check" value="1">Homeless</label>
- </div>
- <button class="submit btn btn-custom " type="submit" name='Submit' value='submit'>Search</button>
- </div>
- </div><!-- /.from-group -->
- </form>
- </div><!-- /.col -->
- </div><!-- /.row -->
- <hr>
- <div class="row">
- <div class="col-md-12">
- <?php
- if (!empty($_POST)) {
- echo "here's what we found";
- foreach ($interested_users as $result) {
- echo $result->fname.' '.$result->lname.'<br />';
- }
- }
- ?>
- </div><!-- /.col -->
- </div><!-- /.row -->
- </div> <!-- /container -->
- </div> <!-- /#page-wrapper -->
- <!-- footers -->
- <?php require_once $abs_us_root.$us_url_root.'users/includes/page_footer.php'; // the final html footer copyright row + the external js calls ?>
- <!-- Place any per-page javascript here -->
- <?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