-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclass.user.php
More file actions
executable file
·87 lines (78 loc) · 1.79 KB
/
class.user.php
File metadata and controls
executable file
·87 lines (78 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
require_once 'dbconfig.php';
class USER
{
private $conn;
public function __construct()
{
$database = new Database();
$db = $database->dbConnection();
$this->conn = $db;
}
public function runQuery($sql)
{
$stmt = $this->conn->prepare($sql);
return $stmt;
}
public function lasdID()
{
$stmt = $this->conn->lastInsertId();
return $stmt;
}
public function is_logged_in()
{
if(isset($_SESSION['userSession']))
{
return true;
}
}
public function GetRows($sql) {
try {
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return $results;
}catch(Exception $e) {
die ( $e->getMessage() );
}
}
public function Insert($sql) {
try {
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
return $this->conn->lastInsertId();
}catch(Exception $e) {
return $e->getMessage();
}
}
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 = "";
$mail->Host = "mail.zivent.co.ke";
$mail->Port = 25;
$mail->AddAddress($userEmail);
$mail->Username="autoresponder@zivent.co.ke";
$mail->Password="Autoresponder401h8*";
$mail->SetFrom('autoresponder@zivent.co.ke','Wedding Gowns');
$mail->AddReplyTo("dc_dalin@zivent.co.ke","Wedding Gowns");
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->Send();
}
}