-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotify.php
More file actions
59 lines (46 loc) · 1.3 KB
/
notify.php
File metadata and controls
59 lines (46 loc) · 1.3 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
<?php
// Check Page Is Request
if(empty($_POST)) {
header("location: index.php");
exit();
}
// Create An Array To Store Error ["If Generated "]
$errors = array();
// Check For Empty Field [ "Server Side Validation" ]
if(empty($_POST["txtName"]))
$errors[] = "Name Is Empty";
if(empty($_POST["txtMessage"]))
$errors[] = "Message Is Empty";
// Check There Is Any Error Or Not
if(!empty($errors)) {
header("location: index.php");
exit();
}
// Include Library
require_once('lib/Pusher.php');
// Set Variables
$cluster = ""; // Enter Your App Cluster
$appId = ""; // Enter App ID Here
$appKey = ""; // Enter Your Key Here
$appSecret = ""; // Enter Your Secret Key Here
// Set Cluster
$options = array(
'cluster' => 'ap2',
'encrypted' => false
);
// Create Object Of PUSHER Class
$pusher = new Pusher(
$appKey,
$appSecret,
$appId,
$options
);
// Create Array Of Data For Notification
$data["message"] = $_POST["txtMessage"];
$data["name"] = $_POST["txtName"];
// Send Notification
$pusher->trigger('my-channel', 'my-event', $data);
// Go Back To index Page
header("location: index.php");
exit();
?>