Member

[insert_php]
if(!isset($_SESSION)){session_start();}
$hostname = “mysql1005.mochahost.com”;
$database = “fosco1_foscopa”;
$username = “fosco1_wp527”;
$password = “S82..2qi9p”;
$connStr = ‘mysql:host=mysql1005.mochahost.com;dbname=fosco1_foscopa’;
$user = ‘fosco1_wp527’;
$pass = ‘S82..2qi9p’;
//set_exception_handler(‘exceptionHandler’);
try
{
$conn = new PDO($connStr, $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
showError(“Sorry, an error has occurred. Please try your request
later\n” . $e->getMessage());
}

if (isset($_SESSION[‘mid’])){

if (isset($_SESSION[‘mid’])) {$mid=$_SESSION[‘mid’];}
// Issue the query

$members = $conn->query(“SELECT members.f_mid, members.f_address, members.f_city, members.f_country, members.f_email, members.f_place_of_work, members.f_surname, members.f_year_group, members.f_title, members.f_othername, members.f_sex, members.f_photo, members.f_phone_mobile, members.f_phone_work, members.f_occupation FROM members where members.f_mid=’$mid'”);
$members->setFetchMode(PDO::FETCH_ASSOC);
$rmember=$members->fetch();

$users =$conn->query(“SELECT loggers.lid FROM loggers where loggers.f_mid=’$mid'”);
$users->setFetchMode(PDO::FETCH_ASSOC);
$euser=$users->fetch();
}
if(isset($_POST[‘f_search’])) {
if (isset($_GET[“page”])) { $page = $_GET[“page”]; } else { $page=1; };
$results_per_page=50;
$start_from = ($page-1) * $results_per_page;

$queried = $_POST[‘f_search’]; // always escape

$keys = explode(” “,$queried);

$search= “SELECT distinct(members.f_mid), members.f_address, members.f_city, members.f_country, members.f_email, members.f_place_of_work, members.f_surname, members.f_year_group, members.f_title, members.f_othername, members.f_sex, members.f_photo, members.f_phone_mobile, members.f_phone_work, members.f_occupation FROM members where f_surname = ‘$queried’ “;
foreach($keys as $k){
$search .= ” or members.f_year_group = ‘$k’ or f_surname = ‘$k’ or f_othername=’$k’ or f_city = ‘$k’ or f_country = ‘$k’ “;}
$search .= “ORDER BY IF(members.f_year_group = ‘$k’,1,0)+
IF(members.f_surname = ‘$k’,1,0)+
IF(members.f_othername = ‘$k’,1,0) +
IF(members.f_city = ‘$k’,1,0) +
IF(members.f_country = ‘$k’,1,0) DESC limit $start_from, $results_per_page”;

$search_num= “SELECT count(distinct(members.f_mid)) as num FROM members where f_surname = ‘$queried’ “;
foreach($keys as $k){
$search_num .= ” or members.f_year_group = ‘$k’ or f_surname = ‘$k’ or f_othername=’$k’ or f_city = ‘$k’ or f_country = ‘$k’ “;}
$search_num=$conn->query($search_num);
$search_num->setFetchMode(PDO::FETCH_ASSOC);
$rsearch_num=$search_num->fetch();

}

if ((isset($_GET[‘member’])) && ($_GET[‘member’] != “”)) {
$id = ($_GET[‘member’]);

// Build the SQL query to delete the details
$sql_delete = “DELETE FROM members WHERE mid=:id”;
$sqldelete=$conn->prepare($sql_delete);
$sqldelete->bindParam(“:id”, $id);
$result=$sqldelete->execute();

$sql_delete = “DELETE FROM users WHERE mid=:id”;
$sqldelete=$conn->prepare($sql_delete);
$sqldelete->bindParam(“:id”, $id);
$result=$sqldelete->execute();

$path = ‘https://www.fosco.edu.gh/wp-content/uploads/fphp/foscopa_images/’.$id.’.jpg’ ;
chown($path, 666);
unlink($path);
}

echo ‘

Member

‘. $rmember[‘f_title’].’ ‘.$rmember[‘f_othername’]. ‘ ‘. $rmember[‘f_surname’] .’

‘. $rmember[‘f_occupation’] .’

‘. $rmember[‘f_place_of_work’] .’

‘. $rmember[‘f_address’] .’
‘.
$rmember[‘f_city’] .’
‘.
$rmember[‘f_country’] .’

‘. $rmember[‘f_email’] .’

‘. $rmember[‘f_phone_mobile’] .’


‘. $rmember[‘f_year_group’] .’

Group

‘. $rmember[‘f_phone_work’] .’

Phone – Work

Search

 

‘;

if (isset($_POST[‘f_search’])) {
echo ‘

‘.
$rsearch_num[‘num’] .’
‘;
if($rsearch_num[‘num’]==’1′ ){ echo ‘ member found’; } else {echo ‘ members found’;} echo ‘

‘;
if((isset($_SESSION[‘role’])) && $_SESSION[‘role’] !=’member’){
echo ‘

‘;
}
echo ‘

‘;
foreach($conn->query($search) as $r) {
echo ‘

‘;
if((isset($_SESSION[‘role’])) && $_SESSION[‘role’] !=’member’){
echo ‘

‘;
}
echo ‘

‘;
}
echo ‘

Photo Name Year Group Phone Number Email
‘. $r[‘f_title’].’ ‘.$r[‘f_othername’].’ ‘. $r[‘f_surname’] .’ ‘. $r[‘f_year_group’] .’ ‘. $r[‘f_phone_mobile’] .’ ‘. $r[‘f_email’] .’

‘;
if ($rsearch_num[‘num’] > $results_per_page) {
echo ‘

    ‘;
    for ($i=1; $i<=$total_pages; $i++) { echo '
  • ‘. $i .’
  • ‘;
    }
    echo ‘

‘;
}
echo ‘

‘;
}
echo ‘

‘;

[/insert_php]