-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplymessagestech.php
executable file
·84 lines (71 loc) · 2.08 KB
/
replymessagestech.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
<?php
// Include config file
require_once "dbconfig.php";
// Define variables and initialize with empty values
$techusername = $message = $sweet = "";
// Processing form data when form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){
if (isset($_POST['techusername'])) {
$techusername = $_POST['techusername'];
}
if (isset($_POST['message'])) {
$message = $_POST['message'];
}
// Check input errors before inserting in database
if(empty($sweet)){
// Prepare an insert statement
$sql = "INSERT INTO technicianadminmessages (techusername, message) VALUES (?, ?)";
if($stmt = mysqli_prepare($conn, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "ss", $param_techusername, $param_message);
// Set parameters
$param_techusername = $techusername;
$param_message = $message;
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
// Redirect to login page
$sweet = 'success';
$feedback = 'Your Message Was Sent Successfully, Thank you for your feedback.';
} else{
$sweet = 'error';
$feedback = 'Something went wrong. Please try again later.';
}
}
// Close statement
mysqli_stmt_close($stmt);
}
// Close connection
mysqli_close($conn);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Reply Messages.</title>
<!-- sweet alert -->
<link rel="stylesheet" href="css/sweetalert.css">
<script src="js/sweetalert.js"></script>
<script src="js/jquery.js"></script>
<link rel="stylesheet" href="css/all.min.css" />
<style>
body{
background: #fff;
}
</style>
</head>
<body>
<?php
// $sweet = "";
if($sweet == 'error'){
echo "<script>swal('Error', '".$feedback."')</script>";
}elseif($sweet == 'success'){
echo "<script>swal('Success', '".$feedback."')</script>";
}
?>
<a href="techDashBoard.php">DashBoard
<br><i class="fa fa-arrow-left fa-4x"></i></a>
</body>
</html>