-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
112 lines (74 loc) · 2.56 KB
/
index.php
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
require 'vendor/autoload.php';
use Mailgun\Mailgun;
if(isset($_POST['submit'])){
if(!empty($_POST['from']) && !empty($_POST['to']) && !empty($_POST['subject']) && !empty($_POST['message'])) {
$sender = $_POST['from'];
$receiver = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$mg = Mailgun::create('your-apikey'); // For US servers
$mg->messages()->send('yourDomain', [
'from' => $sender,
'to' => $receiver,
'subject' => $subject,
'text' => $message
]);
} else {
echo 'empty fields!!';
header('Location: index.php');
}
}
?>
<!DOCTYPE html>
<div class="box">
<div class="containerGrid" >
<html>
<head>
<link rel="stylesheet" href="style/style.css?v=<?php echo time();?>"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<header>
<div class="itemHeader">
<?php include 'template/header.php' ?>
</div>
</header>
<body>
<form action="index.php" method="POST" id="form">
<div class="sideBar">
<p>From</p>
<input type="email" placeholder="ex: [email protected]" name="from" require/><br>
<p>To</p>
<input type="email" placeholder="ex: [email protected]" name="to" require/>
</div>
<div class="main">
<p>Subject</p>
<input type="text" name="subject" placeholder="Enter text here" require><br>
<p>Message</p>
<textarea name="message" rows="4" cols="50" form="form" placeholder="Enter text here" id="quote"></textarea>
</div>
<button type="button" onclick="generate();" style="color: black;">Generate</button><input type="submit" name="submit" id="submitBtn" value="send">
<br>
<br>
</form>
</body>
<footer>
<div class="footer">
</div>
</footer>
</html>
</div>
</div>
<script type="text/javascript">
function generate() {
fetch("https://type.fit/api/quotes")
.then(function(response) {
return response.json();
})
.then(function(data) {
console.log(data);
var number = Math.floor((Math.random() * 1000) + 1);
document.getElementById("quote").value = data[number].text;
});
}
</script>