dbConnection(); $this->conn = $db; } public function runQuery($sql) { $stmt = $this->conn->prepare($sql); return $stmt; } public function lasdID() { $stmt = $this->conn->lastInsertId(); return $stmt; } //apply public function events($usern,$age,$mst,$colo,$hight,$bgp,$geno) { try { $nullval = 'nulls' ; $stmt = $this->conn->prepare("INSERT INTO contestant(username,birthdate,marriage_status,complexion,height,blood_group,genotype,nationality,state,lga,village,Residential,phoneno,nextkin,nextkin_no,image) VALUES(:us,:bd,:ms, :clo, :ht, :bg, :gn, :nat,:st,:lg,:vi,:res,:ph,:nx,:nxn,:im)"); $stmt->bindparam(":us",$usern); $stmt->bindparam(":bd",$age); $stmt->bindparam(":ms",$mst); $stmt->bindparam(":clo",$colo); $stmt->bindparam(":ht",$hight); $stmt->bindparam(":bg",$bgp); $stmt->bindparam(":gn",$geno); $stmt->bindparam(":nat",$nullval); $stmt->bindparam(":st",$nullval); $stmt->bindparam(":lg",$nullval); $stmt->bindparam(":vi",$nullval); $stmt->bindparam(":res",$nullval); $stmt->bindparam(":ph",$nullval); $stmt->bindparam(":nx",$nullval); $stmt->bindparam(":nxn",$nullval); $stmt->bindparam(":im",$nullval); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } //update public function update($usern,$nat,$sta,$lga,$villa,$res,$phone,$next,$nexn) { try { $stmt = $this->conn->prepare("update contestant set nationality = :nat, state =:st, lga =:lg, village =:vi, residential =:res, phoneno =:ph, nextkin =:nx, nextkin_no =:nxn where username =:un") ; $stmt->bindparam(":un",$usern); $stmt->bindparam(":nat",$nat); $stmt->bindparam(":st",$sta); $stmt->bindparam(":lg",$lga); $stmt->bindparam(":vi",$villa); $stmt->bindparam(":res",$res); $stmt->bindparam(":ph",$phone); $stmt->bindparam(":nx",$next); $stmt->bindparam(":nxn",$nexn); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function register($fnames,$gend,$mob,$subj,$qua,$email,$upass,$code) { try { $image = 'avatar' ; $ap = 'NO' ; $password = md5($upass); $stmt = $this->conn->prepare("INSERT INTO members(fname,gender,mobile,subject,qualification,userEmail,userPass,tokenCode,image,approved) VALUES(:fn,:gen,:mob,:subj,:qua,:user_mail,:user_pass,:tk, :img,:ap)"); $stmt->bindparam(":fn",$fnames); $stmt->bindparam(":gen",$gend); $stmt->bindparam(":mob",$mob); $stmt->bindparam(":subj",$subj); $stmt->bindparam(":qua",$qua); $stmt->bindparam(":user_mail",$email); $stmt->bindparam(":user_pass",$password); $stmt->bindparam(":tk",$code); $stmt->bindparam(":img",$image); $stmt->bindparam(":ap", $ap); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function admin($fnames,$mob,$email,$upass,$code) { try { $image = 'avatar' ; // $ap = 'NO' ; $password = md5($upass); $stmt = $this->conn->prepare("INSERT INTO user(fname,mobile,userEmail,userPass,tokenCode,image) VALUES(:fn,:mob,:user_mail,:user_pass,:tk, :img)"); $stmt->bindparam(":fn",$fnames); //$stmt->bindparam(":gen",$gend); $stmt->bindparam(":mob",$mob); //$stmt->bindparam(":subj",$subj); //$stmt->bindparam(":qua",$qua); $stmt->bindparam(":user_mail",$email); $stmt->bindparam(":user_pass",$password); $stmt->bindparam(":tk",$code); $stmt->bindparam(":img",$image); //$stmt->bindparam(":ap", $ap); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function create_blog($fnames,$gend,$uname,$email,$upass,$code,$phone) { try { $password = md5($upass); $stmt = $this->conn->prepare("INSERT INTO pblog(fname,gender,userName,userEmail,userPass,tokenCode,phone) VALUES(:fn,:gen,:user_name, :user_mail, :user_pass, :active_code,:ph)"); $stmt->bindparam(":fn",$fnames); $stmt->bindparam(":gen",$gend); $stmt->bindparam(":user_name",$uname); $stmt->bindparam(":user_mail",$email); $stmt->bindparam(":user_pass",$password); $stmt->bindparam(":active_code",$code); $stmt->bindparam(":ph",$phone); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function loginact($email,$upass) { try { $stmt = $this->conn->prepare("SELECT * FROM pblog WHERE userEmail=:email_id"); $stmt->execute(array(":email_id"=>$email)); $userRow=$stmt->fetch(PDO::FETCH_ASSOC); if($stmt->rowCount() == 1) { //if($userRow['userStatus']=="Y") //{ if($userRow['userPass']==md5($upass)) { $_SESSION['userSession'] = $userRow['userName']; //$_SESSION['usermail'] = $userRow['userEmail']; $_SESSION['userID'] = $userRow['userID']; $_SESSION['loggedin'] = true; return true; } else { header("Location: account.php?error"); exit; } //} //else //{ //header("Location: acount.php?inactive"); //exit; //} } else { header("Location: account.php?error"); exit; } } catch(PDOException $ex) { echo $ex->getMessage(); } } public function login($email,$upass) { try { $stmt = $this->conn->prepare("SELECT * FROM members WHERE userEmail=:email_id"); $stmt->execute(array(":email_id"=>$email)); $userRow=$stmt->fetch(PDO::FETCH_ASSOC); if($userRow['approved'] =='NO') { header("Location: signin.php?errora"); exit; } else { if($stmt->rowCount() == 1) { //if($userRow['userStatus']=="Y") //{ if($userRow['userPass']==md5($upass)) { $_SESSION['userSession'] = $userRow['userEmail']; $_SESSION['usermail'] = $userRow['userEmail']; $_SESSION['subj'] = $userRow['subject']; return true; } else { header("Location: signin.php?errorp"); exit; } //} //else //{ //header("Location: signin.php?inactive"); //exit; //} } else { header("Location: signin.php?erroru"); exit; } } } catch(PDOException $ex) { echo $ex->getMessage(); } } public function authorised ($email,$upass) { try { $stmt = $this->conn->prepare("SELECT * FROM user WHERE userEmail=:email_id"); $stmt->execute(array(":email_id"=>$email)); $userRow=$stmt->fetch(PDO::FETCH_ASSOC); if($stmt->rowCount() == 1) { //if($userRow['userStatus']=="Y") //{ if($userRow['userPass']==md5($upass)) { $_SESSION['staff'] = $userRow['fname']; $_SESSION['admail'] = $userRow['userEmail']; //$_SESSION['subj'] = $userRow['subject']; return true; } else { header("Location: login.php?errorp"); exit; } } else { header("Location: login.php?erroru"); exit; } } //} catch(PDOException $ex) { echo $ex->getMessage(); } } public function is_logged_in() { if(isset($_SESSION['userSession'])) { return true; } } public function redirect($url) { header("Location: $url"); } public function logout() { session_destroy(); $_SESSION['userSession'] = false; } function send_mail($email,$message,$subject) { require_once('mailer/class.phpmailer.php'); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPDebug = 0; $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; $mail->Host = "titano.protonhosting.com"; $mail->Port = 465; $mail->AddAddress($email); $mail->Username="info@greatmadonnamodelacademy.org"; $mail->Password="madonna@2021"; $mail->SetFrom('info@greatmadonnamodelacademy.org','GREAT MADONNA'); $mail->AddReplyTo("info@greatmadonnamodelacademy.org","GREAT MADONNA"); $mail->Subject = $subject; $mail->MsgHTML($message); $mail->Send(); } } ?>