-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessages.php
96 lines (85 loc) · 2.21 KB
/
messages.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
<?php
include('validate.php');
// If any field is not filled properly
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($error) {
header("Location: ./");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Support Messages</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { padding: 2px 20px; }
table, th, td { border: 1px solid black; }
table {
width: 100%;
text-align: left;
border-collapse: collapse;
}
</style>
</head>
<body>
<p><?php if($successful) { echo "Thanks for contacting us $name, we will get back to you shortly through your email, <a href='mailto:$email'>$email.</a>";} ?></p>
<div class="supporthead">
<h1>Support Messages</h1>
<p><a href="./">New Support Message</a></p>
</div>
<?php
include "connect.php";
if ($successful) {
try {
// Set Error mode to PDO Exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = $conn->prepare("INSERT INTO
smessages (name, email, issue, messages)
VALUES (:name, :email, :issue, :message)");
$sql->bindParam(':name', $name);
$sql->bindParam(':email', $email);
$sql->bindParam(':issue', $issue);
$sql->bindParam(':message', $message);
$sql->execute();
echo "Form submitted successfully";
} catch(PDOException $e) {
echo $e->getMessage();
}
}
?>
<div class="smbody">
<table>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Issue</th>
<th>Messages</th>
<th>Edit</th>
</tr>
</thead>
<tbody>
<?php
$query = $conn->prepare("SELECT * FROM smessages");
$query->execute();
$messages = $query->fetchAll();
foreach ($messages as $messages) {
?>
<tr>
<td> <?php echo $messages['name']; ?> </td>
<td> <?php echo $messages['email']; ?> </td>
<td> <?php echo $messages['issue']; ?> </td>
<td> <?php echo $messages['messages']; ?> </td>
<td><a href="edit.php?id=<?php echo $messages['id']; ?>">Edit</a></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php $usernamerr = $emailerr = $issuerr = $messagerr = ""; ?>
</body>
</html>