Your IP : 18.119.19.251


Current Path : /home/lentoinv/churchmr.com/retreat/search/
Upload File :
Current File : //home/lentoinv/churchmr.com/retreat/search/test.php

<?php
session_start(); ob_start();
	   include("../data.inc.php");
	   
$repx = isset($_SESSION['sn'])?$_SESSION['sn']:$_SESSION['rid'];
if($_POST['id']){
$id = $_POST['id']; 
if(regStatus($id)==1){$report = 'User already Registered: '.userName($id);  }
else{
$qur=$db->query("select * FROM mdata WHERE sn='$id' " )or die(mysqli_error());
		  	$r=mysqli_fetch_array($qur);   
			$sid = $r['sid'];
			$rid = $r['rid'];
			$gid = $r['gid'];
			$did = $r['did'];
			$sex = trim($r['sex']);
			$section = trim($r['section']);
			$date = date('ymd');
			
		$sql = $db->query("INSERT INTO event (id,did,gid,rid,sid,sex,date,section,program,rep)
VALUES('$id','$did','$gid','$rid','$sid','$sex','$date','$section','$program','$repx')") or die(mysqli_error());

if($sql){$report = 'Registration Successful: '.userName($id);}
else{ 	$report = 'Error completing Registration, try again: '.userName($id);}
}
}

if($_POST['idx']){
$id = $_POST['idx']; 
$sql = $db->query("DELETE FROM event WHERE id = '$id' AND program = '$program' ") or die(mysqli_error());
$reportx = 'User Un-registratered: '.userName($id);

}

function dName($did,$opt){
	global $db;
$sql = $db->query("SELECT * FROM district WHERE sn = '$did' ");
$row = mysqli_fetch_array($sql);
return $row[$opt];
}

if(array_key_exists('UpdateUser', $_POST)){
$sn = $_GET['user'];
	$surname=$_POST['name'];
	$othername=$_POST['othername'];
	$phone=$_POST['phone'];
	$section=$_POST['section'];
	$address=$_POST['add'];
	$sex=$_POST['sex'];
	$age=$_POST['age'];
	$did = $_POST['district'];
	$den = $_POST['den'];
	$gid = dName($did,'gid');
	$district = dName($did,'district');
	$zone = dName($did,'zone');
	$pass = rand(1000,9999);
 $resul = $db->query(" UPDATE mdata SET surname='$surname', othername='$othername', phone='$phone', section='$section', address='$address', sex='$sex', age='$age', did='$did', gid='$gid', district='$district', zone='$zone', pass='$pass', a='$den' WHERE sn = '$sn' ") or die (mysqli_error());
 $db->query("UPDATE event SET sex='$sex', section='$section', did='$did', gid='$gid', member='$den' WHERE id = '$sn' ") or die (mysqli_error());
 	$report = 'Participant data successfully updated ';
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Auto Registration</title>

    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="../../bootstrap/css/bootstrap.min.css">
    
    <!-- jQuery libs -->
    <script  type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
    <script  type="text/javascript" src="js/jquery-ui-1.7.custom.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.2/modernizr.js"></script>

    <script  type="text/javascript" src="js/jquery-search.js"></script>
<script type="text/javascript">
    $(window).load(function() {
    // Animate loader off screen
    $(".se-pre-con").fadeOut("slow");
  });
</script>

<style type="text/css">
  .no-js #loader { display: none;  }
.js #loader { display: block; position: absolute; left: 100px; top: 0; }
.se-pre-con {
  position: fixed;
  left: 0px;
  top: 0px;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: url(../wait.gif) center no-repeat #fff;
}
</style>
</head>
<body>
<div class="se-pre-con"></div>
<div id="container" style="width:100%; margin:0px;">
<form method="get">
<input type="text" placeholder="Enter Name or Phone No to Search" autofocusx name="SearchUser" style="width: 100%; height:35px; font-size:16px;">
<button style="float:right" type="submit">Search User</button></form></div>
           
         
              <form method="post">  <div>
                  <?php if(isset($_GET['SearchUser'])){ $searchitem = $_GET['SearchUser']; 
                  $fetch =  $db->query("select * from mdata where (surname like '%".$searchitem."%' or othername like '%".$searchitem."%' or phone like '%".$searchitem."%') and rid = '$rid' order by surname asc, othername asc limit 0,200");
$num=mysqli_num_rows($fetch);
 $sResults = '';
      $sResults .= '<table class="table table-hover no-border" width="100%">
              
                         <tr>
             <th>Tick</td>
             <th>Name</th>
                        <th>Phone/District</th>
                    </tr>';
     
      $x = 0;
        while ( $row = mysqli_fetch_object( $fetch ) ) { $id = $row->sn;
      $x = $x + 1;
       if(regStatus($id)==1){ $col = 'bgcolor="#99FF99"'; } else{ $col = '';}
      
      $sResults .= '<tr '.$col.'>';
          //  $sResults .= '<td>' . $x . '</td>';
      $sResults .= '<td>';    
      if(regStatus($id)==1){ $sResults .= '<input name="idx" type="radio" value="'. $id.'" onchange="submit()" >'; }else{ $sResults .= '<input name="id" type="checkbox" value="'. $id.'" style="width:20px; height:20px" onchange="submit()" >'; } $sResults .= '</td><td><a href="?user='.$row->sn.'">' .ucwords(strtolower($row->surname . ' ' . $row->othername)) . '</a></td>';
      $sResults .= '<td>' . $row->district .', ' . $row->section . '</td>';
       $sResults .='</a></tr>';
      
      

        }
   $sResults .= '</table>';

   echo $sResults;

                  }
                  ?>
                </div></form>
              
<script type="text/javascript">
   setInterval(function() {
    $("#refresh").load(location.href+" #refresh>*","");
}, 2000); // seconds to wait, miliseconds. 1s = 1000
 </script>    

            <?php if(isset($report)){  ?> <div id="refresh" >  <?php
				 echo '<div class="alert alert-success alert-dismissible" style="position:fixed; top:50px; z-index:10000">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                <i class="icon fa fa-check"></i> <strong>Alert!</strong> &nbsp;&nbsp;'. $report .'
              </div>';   ?>   </div>   <?php  }  ?>
              
              
              
               <?php if(isset($reportx)){  ?> <div id="refresh" >  <?php
				 echo '<div class="alert alert-danger alert-dismissible" style="position:fixed; top:50px; z-index:10000">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                <i class="icon fa fa-check"></i> <strong>Alert!</strong> &nbsp;&nbsp;'. $reportx .'
              </div>';   ?>   </div>   <?php  }  ?>
  
              
<?php if(isset($_GET['user'])){
  $user = $_GET['user']; 
  
$sq = $db->query("SELECT * FROM mdata WHERE sn = '$user' "); 
$rr = mysqli_fetch_assoc($sq); 

$rid = $rr['rid'];
 ?>

          <div class="box-header">
                      <h4  class="box-title">UPDATE USER   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="?">Close</a> </h4>  
                   </div>
              <div class="panel-body">

                
                 <form method="post">        
                      
               <p> <label> <input name="den" type="radio" value="1" <?php if($rr['a']==1){ echo 'checked'; } ?> required> Member&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label> <label><input name="den" type="radio" value="0" <?php if($rr['a']==0){ echo 'checked'; } ?> > Invitee</label></p>
               <p>
                  <select name="section" class="form-control select2" >
                         <option>SELECT SECTION</option>
                         <option <?php if('Adult'==$rr['section']){ echo 'selected' ; } ?>>Adult</option>
                          <option <?php if('Campus'==$rr['section']){ echo 'selected' ; } ?>>Campus</option>
                          <option <?php if('Youth'==$rr['section']){ echo 'selected' ; } ?>>Youth</option>
                          <option <?php if('Children'==$rr['section']){ ?> selected <?php } ?> >Children</option>
                        
                        </select>
                  
                   
               </p>
               <p>
 <select name="district" class="form-control select2">
 
                          <?php 
              $query=$db->query("select * FROM district WHERE rid='$rid' ORDER BY zone ASC, district ASC " )or die(mysqli_error());
              while($row=mysqli_fetch_array($query)){
            
              ?>
                          <option <?php if($row['sn']==$rr['did']){ echo 'selected' ; } ?> value="<?php echo $row['sn'] ?>"><?php echo $row['zone'].' / '.$row['district']; ?></option>
                          <?php }  ?>
                        </select>
</p>

                 <p>
                  <input name="name" class="form-control" placeholder="Surname*" value="<?php echo $rr['surname']; ?>" required >
                   </p>
                   
                    <p>
                  <input name="othername"  class="form-control" placeholder="Other Names" value="<?php echo $rr['othername']; ?>" required>
                   </p>
                   <p>
                  <input name="phone"  class="form-control" placeholder="Phone Number" value="<?php echo $rr['phone']; ?>" >
                   </p>
                   

                    <p>
                      <textarea id="editor1x" name="add" class="form-control" placeholder="Detailed Residential Address" rows="2"  required><?php echo $rr['address']; ?></textarea>
                     
                      </p>
                      
               
                       <p> <strong>Gender</strong> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="sex" type="radio" value="Male" <?php if($rr['sex']=='Male'){ echo 'checked'; } ?> required> Male&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="sex" type="radio" value="Female" <?php if($rr['sex']=='Female'){ echo 'checked'; } ?>> Female</p>
                     
            <p> Age Group
                      <select name="age" class="form-control">
                                 
                                  <option selected><?php echo $rr['age']; ?></option>
                                  <option>1-3</option>
                                  <option>4-6</option>
                                  <option>7-9</option>
                                  <option>10-12</option>
                                 
                                  <option>13-16</option>
                                  <option>17-20</option>
                                  <option>21-25</option>
                                  
                                  <option>26-30</option>
                                  <option>31-35</option>
                                  <option>36-40</option>
                                  <option>41-45</option>
                                  <option>46-50</option>
                                  <option>51-60</option>
                                  <option>61-90</option>
                                 
                                </select></p>
                                
<button type="submit" class="btn btn-primary" name="UpdateUser" style="width:100%">UPDATE USER</button>  
                     
                    </p>
                    </form>  
                    

                </div><!-- /.tab-content -->

<?php  } ?>  
            
</div>
<script src="../../bootstrap/js/bootstrap.min.js"></script>
</body>
</html>

?>